1, to ensure that the system has dependencies libaio
[root@localhost ~]# yum -y install libaio
2, extract the package
[root@localhost ~]# tar -xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local
3, flexible connector disposed
[root@localhost ~]# cd /usr/local/ [root@localhost local]# ln -s mysql-5.7.24-linux-glibc2.12-x86_64/ mysql
4. Create a user
[root@localhost local]# useradd -M -s /sbin/nologin mysql
5, the installation path of users and groups to mysql
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql
6, initialization obtain the password
[root@localhost local]# /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --initialize
7, modify the configuration file
[root@localhost local]# 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
8, copy the script
[root @ localhost local] # cp MySQL / Support-Files / /etc/init.d/ mysql.server mysqld [root @ localhost local] # chmod + the X-/etc/init.d/mysqld // add execute permission to the script
9, add a script service, start service with systemctl
[root @ localhost local] # chkconfig --add mysqld // add to the script service [root @ localhost local] # systemctl start mysqld
10, see the port
[root@localhost local]# netstat -anpt | grep :3306 tcp6 0 0 :::3306 :::* LISTEN 3224/mysqld
11, log database
[root @ localhost local] # MySQL-uroot--p ' / jWpQ & VVl9Mp ' - bash: MySQL: command not found [root @ localhost local] LN # / usr / local / MySQL / bin / MySQL / bin // make a soft link [root @ localhost local] # MySQL -uroot--p ' / jWpQ & VVl9Mp ' // you can log in the database
12, change passwords
[root@localhost ~]# mysqladmin -uroot -p'/jWpQ&VVl9Mp' password 123123 [root@localhost ~]# mysql -uroot -p123123
13, if you forget the password, crack the code (to find a free time, does not affect the normal use)
[root @ localhost ~] # systemctl STOP mysqld // close the database to ensure that no one associated with the mysql process [root @ localhost ~] # PS the AUX | grep mysqld root 3291 0.0 0.0 112.66 thousand 972 PTS / 0 R + 23 : 55 0 : 00 grep --color = Auto mysqld [root @ localhost ~] # mysqld_safe --skip-Grant-the tables & // skip into the background authorization form to start the service, start the service when you do not need a user name and password when landed [root @localhost ~] # MySQL