Installing MySQL-5.7.24 based on general binary mode

Keywords: MySQL Linux Database yum

1. Ensure that there is a dependent libaio software in the system. Use the following command

[root@localhost ~]# yum -y install libaio
[root@localhost ~]# rpm -q libaio
libaio-0.3.109-13.el7.x86_64


2. Use wget command to download mysql-5.7.24 package

[root@localhost ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz


3. Extract the mysql installation package to the specified directory. The command is as follows:

[root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/


4. Enter / usr/local directory

[root@localhost ~]# cd /usr/local/


5. Create a soft link for mysql installation directory

[root@localhost local]# ln -s mysql-5.7.24-linux-glibc2.12-x86_64/ mysql


6. Add mysql users and groups and

[root@localhost local]# useradd -M -s /sbin/nologin mysql


7. Modify the current directory owner to a new mysql user. The command is as follows:

[root@localhost mysql]# chown -R mysql:mysql ./


8. Initialize mysql database (set up default database and table). The command is as follows:

[root@localhost mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

Record the randomly generated login password: e9iIEYBa9t!f


9. Open mysqld service. The command is as follows

[root@localhost mysql]# vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
[root@localhost mysql]# ./support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/mariadb.log'.
. SUCCESS!
[root@localhost mysql]# netstat -lnpt |grep :3306
tcp6       0      0 :::3306                 :::*                    LISTEN      2220/mysqld


10. Add the mysqd service to the system service. The command is as follows

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# ls -l /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10576 12 month  7 16:12 /etc/init.d/mysqld
[root@localhost mysql]# service  mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!


11. Log in to mysql database with random password. The command is as follows

[root@localhost mysql]# ./bin/mysql -u root -p

Wait for the system prompt and enter the random password to log in


12. Set the new password of mysql management user root

[root@localhost mysql]# ./bin/mysqladmin -u root -p'e9iIEYBa9t!f' password '123456'


13. Add mysql command to the system command execution path for easy use.

[root@localhost mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[root@localhost mysql]# cd
[root@localhost ~]# mysql -u root -p123456


Posted by mvleus on Sun, 01 Dec 2019 13:10:31 -0800