Install MYSQL 5.7 on CentOS 7


Install MYSQL 5.7 on CentOS 7. Currently, Mysql is encouraging version 8. However, our project is still running with mysql 5.7. Upgrading to mysql 8 will have many problems. Therefore, the choice is still to install mysql 5.7. This article will guide you step by step to install MYSQL 5.7. It is similar to other RHEL.

Step 1: Check the current mysql rpm packages

You should make sure on Server there is no mysql rpm packages. Check:

rpm -qa | grep mysql

If there is still mysql rpm package. Delete it:

rpm -e --nodeps <oackage_name>

Step 2: Download packages to install Mysql 5.7 on CentOS 7

You need to download 4 packages to install MYSQL:


Step 3: Install Mysql 5.7

Now, you can install from the above 4 packages.

yum localinstall mysql-community-common-5.7.26-1.el7.x86_64.rpm
yum localinstall mysql-community-libs-5.7.26-1.el7.x86_64.rpm
yum localinstall mysql-community-client-5.7.26-1.el7.x86_64.rpm
yum localinstall mysql-community-server-5.7.26-1.el7.x86_64.rpm

Then, start mysqld and turn on mysqld at startup.

systemctl start mysqld
systemctl enable mysqld

Step 4: Login Mysql

Now, you have to get a temporary password to login.

sudo grep "temporary password" /var/log/mysqld.log

Get the password, log in with:

mysql -u root -p

After logging in, you need to reset the password. Use the following command:

ALTER USER 'root'@'localhost' IDENTIFIED BY '<new_password>';

Now, you have successfully installed MySQL 5.7. You can see more about LEMP when installing Server: Install Nginx, MySQL, PHP 7 – LEMP on CentOS 7

If you have any questions, please leave a comment for us to discuss.

Leave a Reply