Categories: CentOSLinuxShell

How to Install MySQL 8 on CentOS 8

MySQL Server is the most popular tool used for relational databases. It hosts multiple databases using a single server where allows multi-user can access these databases individually. At the time, when we are writing this article MySQL Server 8.0 is available for installation. This version introduced some new features that are not compatible with some applications. So, first, read the application documentation before deploy on CentOS 8 server.

In this article, we will explain how to install MySQL on CentOS 8 using the terminal. We will also show you how to get started with using MySQL 8.

Installation of MySQL on CentOS 8

To install MySQL server on your system, you need to do the following steps:

Step 1. Login as root user on your system. So, you can install some necessarily required packages on CentOS 8.

Step 2. Open the terminal by pressing ‘Ctrl + Alt + t’. Or you can also launch the terminal application from the application launcher as follows:

Step 3. Now, you will install MySQL server 8 on your system using the Yum package manager. Type the following command on the terminal:

$ sudo dnf install @mysql

You will press ‘y’ to download and install the MySQL dependencies. Using the @mysql module, all dependencies and MySQL will automatically install on the system.

After a while, a ‘complete’ message will be displayed on the terminal. It’s mean that MySQL has been successfully installed on your system.

Step 4. Once the installation of MySQL server 8 is completed, it’s time to start and enable the service of MySQL by using the following command:

$ sudo systemctl enable --now mysqld

Step 5. It is recommended that you must check the MySQL service running status before to start as follows:

$ sudo systemctl status mysqld

You can see in the following screenshot services of MySQL are running on my system.

Step 6. To set the secure root password for MySQL server, you will run the following script:

$ sudo mysql_secure_installation

After executing the above script, it will ask you to configure a component for password validation named as ‘validate_password’. You will press ‘y’ and hit ‘Enter’ key. It will automatically configure the validate password component. In the next prompt, it will ask you about password length, three options will available on your terminal: 0: low, 1: medium, 2: strong. You will select the option ‘2’ for a strong password. Now, you will set the root password. Enter the new root password and then again you need to re-type the root password. After that, more user prompts will appear on the terminal to confirm the following questions:

  1. Either you want to remove the anonymous user?
  2. Do you want to restrict a root user to access the local machine?
  3. Do you want to remove the test database?
  4. Want to reload privileges of the table?

You must answer ‘yes’ or type ‘y’ to all needed questions and further proceed.

Step 7. Now, you will interact with MySQL server using the command line. Type the following command to start the MySQL environment:

$ mysql -u root -p

You need to enter the root password which you have defined above. Now, your MySQL server 8 with secure configuration has been installed on your system. Now, you can explore more MySQL command by working on it.

Create a database using MySQL server

To create a database named ‘vitux’, you will run the following command:

mysql> create database vitux;

More, you can grant prvillages to users using the following command:

mysql> GRANT ALL ON vitux.* TO kbuzdar@localhost IDENTIFIED BY 'kbuzdar123';

If you want to close the MySQL command line environment then simple you will write the following command that will switch to a normal shell.

mysql> exit

Conclusion

In this article, you have learned how to install MySQL server 8 on CentOS 8 system. I hope you liked this article and would be useful for you in the future. Please give us your feedback via comments in the comment box.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago