1. Download the software: ( Note: you need to log in to the Oracle account to download )
1.1 Download address: https://dev.mysql.com/downloads/mysql/
1.2 For official installation documents, please refer to: https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
1.3 Select parameters:
1.3.1 Find other stable version download
1.3.2 Select the corresponding version to download
2.创建文件夹:# mkdir -p /data0/mysql && mkdir -p /data1/mysql && mkdir -p /data1/mysql/temp && mkdir -p /data1/mysql/data && mkdir -p /data1/mysql/logs
3. Unzip the file and rename it:
3.1 Copy the file to the / data0 / mysql folder
3.2 Unzip the file to the current folder
3.2.1 Enter this folder first: # cd / data0 / mysql
3.2.2 # tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
Note: The file name unzipped here is: mysql-5.7.28-linux-glibc2.12-x86_64
3.2.3 Rename: # mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql-5.7
4. Create users and groups:
4.1 # groupadd mysql
4.2 # useradd -r -g mysql mysql
5. Permission modification:
5.1 chown -R mysql:mysql /data0/mysql
5.2 chown -R mysql:mysql /data1/mysql
6. Configuration service: (cp: cope)
6.1 # cp /data0/mysql/mysql-5.7/support-files/mysql.server /etc/init.d/mysql
6.2 Modify configuration information: # vi /etc/init.d/mysql
6.3 Modify parameters:
# basedir=/data0/mysql/mysql-5.7
# datadir=/data1/mysql/data
Type esc, enter: x to save and exit
7. Set the configuration file
7.1 Delete the original configuration file
# cd / etc
# rm -rf my.cnf
7.2 Edit file:
# vi my.cnf
Add the following (for reference only):
[client]
socket = /data1/mysql/temp/mysql.sock
[mysqld]
basedir = /data0/mysql/mysql-5.7
datadir = /data1/mysql/data
tmpdir = /data1/mysql/temp
socket = /data1/mysql/temp/mysql.sock
log-error = /data1/mysql/logs/error.log
pid-file = /data1/mysql/mysql.pid
user = mysql
8. Configure environment variables:
8.1 Modification: # vi / etc / profile
8.2 Add at the end of the file:
# export PATH=/data0/mysql/mysql-5.7/bin:/data0/mysql/mysql-5.7/lib:$PATH
# export PATH
Click Esc, enter: x and save and exit
8.3 Make the configuration effective: source / etc / profile
9. Initialize the database
9.1 Enter: cd /data0/mysql/mysql-5.7
9.2 初始化:bin/mysqld --initialize-insecure --user=mysql --basedir=/data0/mysql/mysql-5.7 --datadir=/data1/mysql/data
10. Start the service : # service mysql start
10.1 Note:
Close the service (modify my.cnf, you need to restart the service to use)
# service mysql stop
11. Set the boot to start: # chkconfig mysql on
12. Modify the default password: # mysqladmin -u root password "root"
13. Set up remote connection:
13.1 mysql -uroot -p
13.2 root
13.3 Modify the remote connection: # GRANT ALL PRIVILEGES ON *. * TO 'root' @ '%' IDENTIFIED BY 'root' WITH GRANT OPTION;
13.4 Refresh parameter: # FLUSH PRIVILEGES; ( Note: after modification, you need to turn off the firewall to access. )
13.5 Exit sql command: # exit;
14. Remote connection test:
15. Successful connection