Install mysql 5.7.17 under CentOS 7

I have many experiences of installing the latest version of mysql5.7 under CentOS 7:

1. Follow this article to install mysql on CentOS 7, the mysql version I chose is 5.7.17.

2. Follow this article .

3. Install the official website document operation.

It is found that if you need to install the latest version of mysql, the operation steps on the official website are the most convenient and fast. However, there are many instructions on the official website that have nothing to do with CentOS 7. Now, after removing the contents unrelated to CentOS 7, they are sorted as follows:

First, prepare, delete the mariaDB installed by default on CentOS 7

[root@5201351 ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@5201351 ~]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64 --nodeps

 2. Download and install the mysql source of yum.

    1. Download mysql57-community-release-el7-9.noarch.rpm at https://dev.mysql.com/downloads/repo/yum/

     

sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm

   2. Install and start mysql

yum install mysql-community-server --install mysql
systemctl start mysqld -- start mysql
systemctl status mysqld -- check whether mysql started successfully

  3. Modify the root password. When mysql5.7 is started for the first time, a random password will be generated in the log file.

  

grep 'temporary password' /var/log/mysqld.log -- get random password
mysql -uroot -p --Enter the random password obtained earlier
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; -- change root password

 4. The above mysql installation is complete. The firewall of CentOS 7 is firewall, which is enabled by default. At this time, the external network cannot access mysql. It can be adjusted as follows:

firewall-cmd --permanent --zone=public --add-port=3306/tcp --open port 3306
firewall-cmd --reload --reload configuration
firewall-cmd --list-all -- check if the configuration is successful

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326393245&siteId=291194637