1) based on Source Package Installation MySQL
[Root @ localhost ~] # rpm -q mysql mysql-server mariadb mairadb-server // check the package has not been installed rpm format will uninstall
ncurses-devel dependencies are cmake
[root@localhost ~]#yum -y install ncurses-devel cmake
[root@localhost ~]#rpm -q ncurses-devel cmake
Import mysql package (mysql-5.7.24.tar)
[root@localhost ~]#tar xf mysql-5.7.24.tar.gz -C /usr/src/
[root@localhost ~]#cd /usr/src/mysql-5.7.24/
[root@localhost mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc&& make && make install
At this error will be reported a boost!
a. solution to create a file named boost folder under / usr / local
[root@localhost mysql-5.7.24]#mkdir /usr/local/boost
b. enter the directory and download boost
[root@localhost mysql-5.7.24]# cd /usr/local/boost/
[Root @ localhost boost] # import boost package (boost_1_59_0.tar)
[root@localhost boost]#tar xf boost_1_59_0.tar
[root@localhost boost]#cd /usr/src/mysql-5.7.24/
[root@localhost mysql-5.7.24]# yum -y install gcc gcc-c++
[root@localhost mysql-5.7.24]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc -DWITH_BOOST=/usr/local/boost && make && make install
2) adjustment after installation
The database directory permissions
[root@localhost mysql-5.7.24]# chown -R mysql:mysql /usr/local/mysql
[root@localhost mysql-5.7.24]# vim /etc/my.cnf
Replaced by the following four DATADIR = / usr / local / MySQL / Data Socket = / tmp / mysql.sock log-error = / usr / local / MySQL / Data / mysql.log // Error log storage position pid-file = / usr / local / mysql / data / mysql.pid // PID value storage position
3) initialize the database
[root@localhost mysql-5.7.24]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize
2019-09-11T08:01:40.678278Z 1 [Note] A temporary password is generated for root@localhost: FUWehrKBq0(6 //FUWehrKBq0(6是密码
4) set the environment variable
[root@localhost mysql-5.7.24]# vim /etc/profile
Because writing is the absolute path does not modify the PATH value must be added at the end of PATH = $ PATH: / usr / local / mysql / bin
[Root @ localhost mysql-5.7.24] # source / etc / profile // profile is because it is necessary to give effect to the script with source
5) Adding system services
Adding MySQL as a system service, in order to be managed by systemctl command
[root@localhost mysql-5.7.24]# cp /usr/src/mysql-5.7.24/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.7.24]# chmod +x /etc/init.d/mysqld
[root@localhost mysql-5.7.24]# /etc//init.d/mysqld start
Starting MySQL.Logging to '/usr/local/mysql/data/mysql.log'.
SUCCESS!
[root@localhost mysql-5.7.24]# netstat -anpt | grep mysql
tcp6 0 0 :::3306 :::* LISTEN 82911/mysqld
[Root @ localhost mysql-5.7.24] # mysql -u root -p'FUWehrKBq0 (6 '// back into mysql
mysql> exit // Enter exit to exit mysql background
Bye
[Root @ localhost mysql-5.7.24] # mysqladmin -u root -p'FUWehrKBq0 (6 'password' 123456 '// modify the mysql password FUWehrKBq0 (6 replaced by 123456 (modify the database user passwords late :)
[root@localhost mysql-5.7.24]# netstat -anpt | grep mysql
tcp6 0 0 :::3306 :::* LISTEN 82911/mysqld
MYSQL installation is complete