Install MySQL from Source code
Usefull Links
- Community Server
- MySQL source code
- Documents
Compile and Install
Preconfiguration Setup
Create user and group
$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql
$ tar xf mysql-5.7.3-m13.tar.gz
$ cd mysql-5.7.3-m13
Compile and Install
$ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DDEFAULT_CHARSET=gbk \
> -DDEFAULT_COLLATION=gbk_chinese_ci \
> -DENABLED_LOCAL_INFILE=ON \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_FEDERATED_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
> -DWITH_DEBUG=0 \
> -DMYSQL_TCP_PORT=3306
$ make
$ sudo make install
Configuration and Initial
Permission Manager
$ sudo chown -R mysql:mysql /usr/local/mysql
Initial MySQL
$ scripts/mysql_install_db --user=mysql
$ cp support-files/mysql.server /etc/init.d/mysqld
Change Permission again
$ sudo chown -R root .
$ sudo chown -R mysql data
Start mysqld_safe
$ sudo bin/mysqld_safe --user=mysql &
Setup root password
$ sudo ./bin/mysqladmin -u root password '<PASSWORDHERE>'
$ sudo ./bin/mysql_secure_installation
Set Environment
$ sudo bash -c 'cat >> /etc/bash.bashrc' << EOF
> export PATH=/usr/local/mysql/bin:$PATH
> EOF
Check the mysql port
$ sudo netstat -tunlp | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 21712/mysqld
Check variables
$ mysqladmin variables -p
Enter password:
Make mysql as boot start
$ sudo chkconfig --add mysqld
$ sudo chkconfig --level 345 mysqld on