The MySQL official team provides yum repository for the MySQL installation on RPM based systems. Which can be used to install MySQL on CentOS and Fedora systems. This tutorial will help you to Install MySQL Server on CentOS/RHEL 7/6, Fedora 32/31/30/29 using the default package manager.
Step 1 – Configure Yum Repository
First, we need to add the MySQL yum repository in our system provided by MySQL. Execute one of below command as per your operating system version.
Step 2 – Install MySQL Community Server
The MySQL yum repository contains multiple repositories configuration for multiple MySQL versions. So first disable all repositories in mysql repo file. Then execute one of the followings commands as per your operating system to install MySQL.
Step 3 – Start MySQL Service
Start the MySQL server using the following command from the Linux terminal. Using SysVinit Using Systemd
Step 4 – Find MySQL root Password
With the installation of MySQL 5.7, a temporary password is created for the MySQL root user. You can find the temporary password generated in log files. Output:
Step 5 – MySQL Post Install Setup
After installing MySQL first time, execute mysql_secure_installation command to secure MySQL server. It will prompt for few question’s, we recommended to say yes ( y ) for each.
Step 6 – Restart and Enable MySQL Service
After completing all MySQL installation steps and doing all initial settings, restart MySQL service using the following command. Also, enable service to auto start on system reboot with the following command.
Step 7 – Working with MySQL
Now connect mysql database server Linux shell using below command. It will prompt for the password for authentication. On successful login, you will get the MySQL command prompt, where we can execute SQL queries. After login, You can use following commands to create a new database, create a user and assign privileges to the user on the database. Change values as per your requirements.
Congratulations! you have successfully installed MySQL server on your system. Use below quick links for basic MySQL tasks.