22.1 C
Texas
angeloma
Senior Writer and partner

How to install MySQL 8 on CentOS 8?

MySQL is perhaps one of the most important database managers in the world. And to the community version to which we are accustomed, has been added business for that sector. Then, MySQL together with Oracle has become the main dominator of this segment. Of course, there are not the only competent alternatives like PostgreSQL. But due to Oracle’s purchase of MySQL, many Linux distributions have taken it out of their repositories in favor of MariaDB, which is a MySQL fork. Well, in this post as a guide, I will show you step by step how to install MySQL 8 on CentOS 8. Even these steps serve to always have the latest version available.

So, let us start.

Install MySQL 8 on CentOS 8

1) Upgrade your system

This step is optional but I strongly recommend it before you start installing anything on a server. Then, open a terminal or connect to your server and run the following command:

:~$ su
:~# dnf update
- Advertisement -

So, every time we update the system, it installs the latest published security patches. These contain bug fixes that help the system to be much more stable than normal. For this reason, I always recommend doing this step at the beginning.

2) Add the MySQL 8 repository on CentOS 8

Oracle provides a repository of MySQL packages for our CentOS 8 that is also compatible with RHEL 8. This is definitely the safest way to install MySQL 8 on CentOS 8.

First, make sure you have installed wget which is a terminal utility for downloading files from the Internet. We will use it to download the RPM package that contains the repository configuration.

:~# dnf install wget
:~# wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
1.- Downloading the RPM package to add the MySQL repository
1.- Downloading the RPM package to add the MySQL repository

Then, install it.

:~# rpm -ivh mysql80-community-release-el8-1.noarch.rpm
2.- Adding the MySQL repository
2.- Adding the MySQL repository

After that, install MySQL 8 on CentOS by running the following command:

:~# dnf install mysql-server
3.- Install MySQL 8 on CentOS 8
3.- Install MySQL 8 on CentOS 8

Once installed correctly, it is necessary to start the service using systemctl.

:~# systemctl start mysqld

Next, check the service status.

:~#systemctl status mysqld
4.- The MySQL 8 service
4.- The MySQL 8 service

As we can see in the image, MySQL is running smoothly on the server. The next step is to secure the installation. For this, we will use the mysql_secure_installation script that also serves to define the root password of the program.

:~# mysql_secure_installation
5.- Set the new root password
5.- Set the new root password

After defining the root password of the program, you will be asked some configuration questions that you will have to answer as you consider best in your case.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success

Disallow root login remotely? (Press y|Y for Yes, any other key for No) :y
Success

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Dropping test database…
Success. 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

In my case, answer yes to everything.

Finally, access the MySQL console to start working. For now, I will show the basic commands of the console.

:~# mysql -u root -p
> \h
6.- The MySQL 8 commands on CentOS 8
6.- The MySQL 8 commands on CentOS 8

So, that is it.

Conclusion

MySQL despite everything, is still a stable and reliable database management system with good commercial support. However, it is not included in the official repositories of most Linux distributions. But in this post, we have explained the process of installing it in CentOS 8.

You can also learn how to do it in Debian 10.

How to install MySQL on Debian 10?

Please share this post with your friends and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article