Installing MySQL on Linux Using YUM Repository

5.7

# Adding the MySQL YUM Repository.
sudo yum localinstall mysql57-community-release-el7-{version-number}.noarch.rpm
sudo yum-config-manager --enable mysql57-community

# Disabling the Default MySQL Module.
sudo yum module disable mysql

# Installing MySQL.
sudo yum install mysql-community-server

# Starting the MySQL Server.
sudo systemctl enable mysqld --now

# Get root temporary password in the error log file.
sudo grep 'temporary password' /var/log/mysqld.log

# Change the root password.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssw0rd!23';

8.0

~]# sed -ri '/^SELINUX=/c\SELINUX=disabled' /etc/selinux/config
~]# setenforce 0
~]# systemctl stop firewalld
~]# systemctl disable firewalld

~]$ wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
~]$ rpm -ivh mysql80-community-release-el7-2.noarch.rpm
~]# yum makecache
~]# yum repolist
~]# yum list | grep mysql-com
~]# yum -y install mysql-community-server.x86_64

~]# systemctl start mysqld
~]# systemctl enable mysqld

~]# ls /var/lib/mysql
~]# grep 'password' /var/log/mysqld.log
~]# mysql -uroot -p

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'P@ssw0rd!23';