How to Install MySQL 5.7 on Oracle Linux 7

Oracle Linux 7 comes with MySQL yum repository pre-installed. By Default MySQL 8 repository is enabled. You can disable MySQL 8 repository and enable MySQL 5.7 repository to install MySQL 5.7.

https://youtube.com/watch?v=yfr0Wn5gT9U%3Ffeature%3Doembed

You can find enabled repositories with command

yum repolist all |  grep -i mysql

Example

Advertisement

[root@sql2 ~]# yum repolist all |  grep -i mysql
ol7_MySQL55/x86_64                      MySQL 5.5 for Oracle Lin disabled
ol7_MySQL56/x86_64                      MySQL 5.6 for Oracle Lin disabled
ol7_MySQL57/x86_64                      MySQL 5.7 for Oracle Lin disabled
ol7_MySQL80/x86_64                      MySQL 8.0 for Oracle Lin enabled:    281
ol7_MySQL80_connectors_community/x86_64 MySQL 8.0 Connectors Com enabled:     56
ol7_MySQL80_tools_community/x86_64      MySQL 8.0 Tools Communit enabled:     15
[root@sql2 ~]#

Let’s disable MySQL 8 repo and enable MySQL 5.7 repository.

yum install -y yum-utils
yum-config-manager --disable ol7_MySQL80 ol7_MySQL80_connectors_community ol7_MySQL80_tools_community
yum-config-manager --enable ol7_MySQL57

Before you can install MySQL 5.7, if your server has any MySQL 8 related packages installed, you need to uninstall them.

On my server, I had the following packages installed.

[root@mysql1 ~]# rpm -qa | grep mysql
mysql-community-client-plugins-8.0.26-1.el7.x86_64
mysql-community-common-8.0.26-1.el7.x86_64
mysql-community-libs-8.0.26-1.el7.x86_64
mysql-release-el7-1.0-5.el7.x86_64
mysql-community-libs-compat-8.0.26-1.el7.x86_64
[root@mysql1 ~]#

These are installed as dependency for the postfix mail server, so if you remove the packages with yum, postfix also get removed, so I removed it with command

rpm -e --nodeps mysql-community-client-plugins-8.0.26-1.el7.x86_64
rpm -e --nodeps mysql-community-common-8.0.26-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-8.0.26-1.el7.x86_64
rpm -e --nodeps mysql-community-libs-compat-8.0.26-1.el7.x86_64

–nodeps option will remove packages without removing dependent packages. Make sure you don’t remove the package mysql-release-el7-1.0-5.

Now you can install MySQL server with command

yum install mysql-community-server

Enable and start MySQL server

systemctl enable mysqld --now

To find MySQL initial password, use

grep 'temporary password' /var/log/mysqld.log

Login to MySQL server using the temporary password and set a password

mysql -u root -p

Enter the MySQL server temporary password, then execute the following SQL to change the MySQL root password.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_MYSQL_ROOT_PW';

NEW_MYSQL_ROOT_PW – replace with your new secure MySQL root password.

You can secure MySQL installation by running

mysql_secure_installation

Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement