MySQL is known as the world’s most famous and extensively used open-source database management system. MySQL may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL Server.
Install and configure MySQL on CentOS 8; Through this tutorial, we will learn how to install and configure Mysql on centOS 8.
How to Install MySQL on CentOS 8
Just follow the following steps to install MySQL on CentOS 8:
- Step 1 – Install MySQL on CentOS
- Step 2 – Enable MySQL Service
- Step 3 – Check MySQL Server Status
- Step 4 – Secure MySQL
- Step 5 – Manage MySQL Services
Step 1 – Install MySQL on CentOS
First of all, open terminal or command prompt and execute the following command into it to install Mysql on centos:
sudo dnf install @mysql
Step 2 – Enable MySQL Service
Once the installation is complete, start the MySQL service and enable it to automatically start on boot by running the following command:
sudo systemctl enable --now mysqld
Step 3 – Check MySQL Server Status
To verify the status of MySQL by executing the following command on command lien or terminal:
sudo systemctl status mysqld
Once the status check command has been executed, after that, will receive the following output into to the command line or terminal:
● mysqld.service - MySQL 8.0 database server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2019-10-17 22:09:39 UTC; 15s ago ...
Step 4 – Secure MySQL
Now, execute the following command on the command line or terminal to securing to the MySQL server on centOS:
sudo mysql_secure_installation
After that, will be asked to configure the VALIDATE PASSWORD PLUGIN
, which is used to test the strength of the MySQL users’ passwords and improve the security. There are three levels of password validation policy, low, medium, and strong. Press ENTER
if you don’t want to set up the validate password plugin.
On the next prompt, you will be asked to set a password for the MySQL root user. Once you do that, the script will also ask you to remove the anonymous user, restrict root user access to the local machine, and remove the test database. You should answer “Y” (yes) to all questions.
Now execute the following command on command line or terminal to test root user 👤 on centOS system:
mysql -u root -p
Enter the root password when prompted, and will be presented with the MySQL shell as shown below:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.17 Source distribution
Step 5 – Manage MySQL Service
Use the following commands to start, enable, check, stop and restart MySQL services:
Start the MySQL service:
sudo systemctl start mysqld
Set MySQL to start on boot:
sudo systemctl enable mysqld
Check the status of the MySQL service:
sudo systemctl status mysqld
sudo systemctl status mysqld
stop the MySQL service with the following:
sudo systemctl stop mysqld
Prevent the MySQL service from starting at boot:
sudo systemctl disable mysqld
Conclusion
Install and configure MySQL on CentOS 8; Through this tutorial, we have learned how to install and configure Mysql on centOS 8.