This page describes how to install MySql on Red Hat Enterprise and CentOS.
Red Hat Enterprise 8 and CentOS 8
Remove MySql default stream
# dnf remove @mysql
# dnf module reset mysql && sudo dnf module disable mysql
Create Repository File
Store content below into the file /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=0
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=0
Enabling and Installing MySql-5.7
# dnf --enablerepo=mysql57-community install mysql-community-server
Starting MySql Service
# systemctl enable --now mysqld.service
Get the temporary password which was generated during installation:
$ grep 'A temporary password' /var/log/mysqld.log |tail -1
Example output:
2020-02-01T19:13:04.948097Z 1 [Note] A temporary password is generated for root@localhost: .tirhC%r:9kQ
Red Hat Enterprise 7 and CentOS 7
Removing unnecessary MariaDB packages
The Red Hat Enterprise and CentOS contain MariaDB packages which don't allow to install MySql thus is these packages must be removed before MySql can be installed.
# yum remove mariadb-libs
Adding MySql Repository
# yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Installing MySql
# yum install mysql-community-server
Getting MySql started after Reboot
# systemctl enable mysqld
Starting MySql Service
# service mysqld start
Get the temporary password which was generated during installation:
# grep 'temporary password' /var/log/mysqld.log
Example output:
2019-05-09T11:32:13.037069Z 1 [Note] A temporary password is generated for root@localhost: o6Xqb+5r!JRu
Completing MySql Installation
To complete the installation, execute mysql_secure_installation script and follow the wizard. It will prompt for root password. Use the temporary root password.
# /usr/bin/mysql_secure_installation