# MySQL installation on Linux (YUM)

Published 2022-12-03

This tutorial shows you how to install MySQL on Linux 6 (RHEL6/CentOS6) and Oracle Linux 7 (RHEL7/CentOS7) when you have Internet connection. This article has a step-by-step approach and will present you how to install MySQL database on Linux 6 (RHEL6/CentOS6).

When you want to install MySQL Server on Linux, the first thing is to download the RPM package (repository package) from here. I will choose the RPM for "Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package". This RPM is ok for CentOS 6 as well.

I will put this file in a "stage" repository:

From here download the repository package file for the MySQL database Server:

#rpm -Uvh mysql57-community-release-el6-9.noarch.rpm

Now you can install the MySQL database Server:

#yum install mysql-community-server

This command will download and install the following packages:

  • mysql-community-client-5.7.17-1.el6.x86_64.rpm
  • mysql-community-common-5.7.17-1.el6.x86_64.rpm
  • mysql-community-libs-5.7.17-1.el6.x86_64.rpm
  • mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
  • mysql-community-server-5.7.17-1.el6.x86_64.rpm

Now, you can start the MySQL database Server:

[root@idam mysql]# service mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]

However, you have an ERROR (when MySQL is starting), you have to

  • uninstall the MySQL Server : # yum remove mysql mysql-server
  • run # mv /var/lib/mysql /var/lib/mysql_old
  • install again MySQL Server : # yum install mysql mysql-server

You can set the MySQL server to start the service on reboot:

chkconfig mysqld on

Make sure SELinux is running in permissive mode, so you can change the locations of the MySQL files:

setenforce Permissive

and set "SELINUX=permissive" in the "/etc/selinux/config" file (to be permanent).

Now your MySQL database v. 5.7 is installed on Linux6 and ready to be used.