Binary deployment is relatively simple. You can go to mysql official website without installing dependent environment download MySQL binary package. Or through the link of my network disk download , there are auto deployment scripts in the network disk link.
Note: the latest MySQL version 8.0 is completely consistent with the deployment process of this version 5.7, except that the binary package files used are different.
1. Uninstall mariadb
[root@mysql01 ~]# yum -y erase mariadb [root@mysql01 ~]# rpm -e qt-mysql-4.8.7-2.el7.x86_64 --nodeps
2. Deploy mysql 5.7
[root@mysql01 src]# tar zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz [root@mysql01 src]# mv mysql-5.7.28-linux-glibc2.12-x86_64 /usr/local/mysql [root@mysql01 src]# ln -sf /usr/local/mysql/bin/* /usr/local/bin/
3. Edit the configuration file and initialize MySQL
[root@mysql01 src]# rm -rf /etc/my.cnf [root@mysql01 src]# vim /etc/my.cnf #Edit MySQL main profile [mysqld] basedir=/usr/local/mysql datadir=/usr/local/mysql/data pid-file=/usr/local/mysql/data/mysqld.pid log-error=/usr/local/mysql/data/mysql.err socket=/tmp/mysql.sock [client] socket=/tmp/mysql.sock #Create the required directory and users and change the owner [root@mysql01 src]# mkdir /usr/local/mysql/data [root@mysql01 src]# useradd -M -s /sbin/nologin mysql [root@mysql01 src]# chown -R mysql.mysql /usr/local/mysql/ #Initialize MySQL [root@mysql01 src]# mysqld --initialize --user mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data #Add as system service [root@mysql01 src]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld [root@mysql01 src]# chkconfig --add mysqld #Start and set to start automatically [root@mysql01 src]# systemctl enable mysqld [root@mysql01 src]# systemctl start mysqld #Make sure port 3306 is listening [root@mysql01 src]# netstat -anpt | grep 3306 tcp6 0 0 :::3306 :::* LISTEN 2589/mysqld
4. Modify the initial password of MySQL root
#Get the initial password of root [root@mysql01 src]# mysqlpwd=`cat /usr/local/mysql/data/mysql.err | grep password |awk -F'root@localhost: ' '{print $2}'` #Reset password to 123.com [root@mysql01 src]# mysql -uroot -p${mysqlpwd} -e 'alter user root@localhost identified by "123.com"' --connect-expired-password #Login test with new password [root@mysql01 src]# mysql -uroot -p123.com #Additional: help command in MySQL mysql> help show; #This command can check the syntax of all show commands and help + any command word
————————Thank you for reading————————