Step 1 — Installing MySQL

In a web browser, visit:

https://dev.mysql.com/downloads/repo/yum/

Locate the desired version, and update it as needed in the link below:


wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

Once the rpm file is saved, we will verify the integrity of the download by running md5sum and comparing it with the corresponding MD5 value listed on the site:

we’ll install the package:

sudo rpm -ivh mysql57-community-release-el7-9.noarch.rpm

This adds two new MySQL yum repositories, and we can now use them to install MySQL server:

sudo yum install mysql-server

Press y to confirm that you want to proceed. Since we’ve just added the package, we’ll also be prompted to accept its GPG key. Press y to download it and complete the install.

Step 2 — Starting MySQL

We’ll start the daemon with the following command:

sudo systemctl start mysqld

systemctl doesn’t display the outcome of all service management commands, so to be sure we succeeded, we’ll use the following command:

sudo systemctl status mysqld

If MySQL has successfully started, the output should contain Active: active (running) and the final line should look something like:

Note: MySQL is automatically enabled to start at boot when it is installed.

During the installation process, a temporary password is generated for the MySQL root user. Locate it in the mysqld.log with this command:

sudo grep 'temporary password' /var/log/mysqld.log
Make note of the password, which you will need in the next step to secure the installation and where you will be forced to change it. The default password policy requires 12 characters, with at least one uppercase letter, one lowercase letter, one number and one special character.

Step 3 — Configuring MySQL

MySQL includes a security script to change some of the less secure default options for things like remote root logins and sample users.

Use this command to run the security script.

sudo mysql_secure_installation

This will prompt you for the default root password. As soon as you enter it, you will be required to change it.

You’ll be prompted to change the password. Follow the instructions on the command prompt to complete installation.