Install mysql5.6 with centos 7 source code

mysql installation: Reference article 1
mysql compilation error: Reference article 2

1. First, create a directory and enter the command:

mkdir /usr/local/mysql
mkdir /usr/local/mysql/data

2. Then, enter / usr/local/mysql directory, download the compressed package of mysql5.6, and enter the command:

cd /usr/local/mysql
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz

Note: if wget is not installed, execute the command yum install wget

3. Install the dependent packages using yum. Enter the command:

yum -y install cmake bison git ncurses-devel gcc gcc-c++

4. Create a user with the user name mysql and join the mysql user group. Enter the command:

groupadd mysql

useradd -g mysql mysql

5. Unzip mysql-5.6.22.tar.gz and enter the command:

tar zxvf mysql-5.6.22.tar.gz 

6. Enter the decompressed directory and start compiling. It may be a little slow. Enter the command:

cd mysql-5.6.22

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1

make

(1) There may be problems in the process of making. I reported an error here, as shown in the figure below:

(2) . solution: modify sql_acl.cc file, find the error line, line 3215, change single quotation marks into double quotation marks, and enter the command:

vi /usr/local/mysql/mysql-5.6.22/sql/sql_acl.cc

After modification, see the following figure:

(3) . after saving, execute the following command again:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1

make

7. After installation, clean up the temporary data and enter the following command:

make install

make clean

8. To modify the master permission of the directory, enter the command:

chown -R mysql:mysql /usr/local/mysql/data/

chown -R mysql:mysql /usr/local/mysql/

9. Create MySQL Server system tables

(1) . input command:

cd /usr/local/mysql/

scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data

(2) . an error is reported here, as shown in the figure below:

(3) . solution: install autoconf Library:

yum -y install autoconf

(4) . after installation, execute the command again:

scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data

(5) . change the master array of the / usr/local/mysql/my.cnf configuration file generated by initialization to mysql

chown -R mysql:mysql /usr/local/mysql

10. Configuration script startup
(1) Copy mysql startup shell script

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

(2) Start MySQL and enter the command:

/etc/init.d/mysql status

/etc/init.d/mysql start

(3) . startup succeeded

11. Set the startup auto start service as required, and enter the following commands in sequence:

chkconfig --add mysql
chkconfig mysql on

12. Set the mysql soft connection and enter the command:

ln -s  /usr/local/mysql/bin/mysql  /usr/bin

13. Set database password
(1) . input command:

mysql -uroot -p

The default password is blank. Press enter directly

(2) . enter the mysql command line and enter the command:

set password for root@localhost = password('123456');
flush privileges;

(3) . enter exit to exit the command line and re-enter the command:

mysql -uroot -p

Enter the password just set and log in.

14. Then, MySQL 1130 error occurs during remote connection with mysql management tool. Solution:
(1) . enter the mysql command line and enter the following command:

use mysql;
update user set host = '%' where user ='root';

(2) ERROR 1062 (23000): Duplicate entry '% - root' for key 'PRIMARY'

(3) . check whether the host already has the value% and if so, enter the command:

select host,user from user where user='root';

(4) . then refresh and enter the command:

flush privileges;

15. At this time, mysql has been installed, and some problems have been encountered, such as this problem:

Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/

According to the online data, it is found that it is still the same. Therefore, the following operations are carried out:
(1) . delete all files in / usr/local/mysql/data directory
(2) . delete the my.cnf file in / usr/local/mysql directory
(3) , delete the / etc/my.cnf file
(4) , re executed the following commands:

scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

(5) Later, I found that / etc/my.cnf would not be generated. The mysql service was restarted successfully. I don't know what the situation is. Then I just follow the above operation configuration. I don't know whether the environment is different or what. It seems different from what I built before. I'll look at it later. It took so long.. great..

Tags: Database MySQL CentOS

Posted on Wed, 29 Sep 2021 18:59:56 -0400 by h3ktlk