How to Install MySQL 8.0 on CentOS 8 / RHEL 8

MySQL is the most popular, free and open-source relational database management platform, which is used to host multiple databases on any single server by allowing multi-user access to each database.

The latest MySQL 8.0 version is available to install from the default AppStream repository using the MySQL module that is enabled by default on the CentOS 8 and RHEL 8 systems.

There is also MariaDB 10.3 database version is available to install from the default AppStream repository, which is “drop-in replacement” for MySQL 5.7, with some restrictions. If your application is not supported with MySQL 8.0, then I recommend you to install MariaDB 10.3.

In this article, we will walk through you the process of installing the latest MySQL 8.0 version on CentOS 8 and RHEL 8 using the default AppStream repository via YUM utility.

Note: The instructions provided in this article will only work if you have enabled the Red Hat subscription on RHEL 8.

Install MySQL 8.0 on CentOS8 and RHEL 8

The latest version of the MySQL 8.0 is available to install from the default Application Stream repository on CentOS 8 and RHEL 8 systems using the following yum command.

# yum -y install @mysql

The @mysql module will install the most recent version of MySQL with all dependencies.

Install MySQL on CentOS 8 Using AppStream
Install MySQL on CentOS 8 Using AppStream

Once the installation of MySQL completes, start the MySQL service, enable it to automatically start at system boot and verify the status by running the following commands.

# systemctl start mysqld
# systemctl enable --now mysqld
# systemctl status mysqld
Manage MySQL Service in CentOS 8
Manage MySQL Service in CentOS 8

Now secure the MySQL installation by running the security script that carries several security-based operations such as setting the root password, removing anonymous users, disallow root login remotely, remove test database and reload privilege.

# mysql_secure_installation
Secure MySQL Installation in CentOS 8
Secure MySQL Installation in CentOS 8

Once MySQL installation is secured, you can log in to the MySQL shell, and start creating new databases and users.

# mysql -u root -p
mysql> create database tecmint;
mysql> GRANT ALL ON tecmint.* TO ravi@localhost IDENTIFIED BY 'ravi123';
mysql> exit

That’s all! In this article, we’ve explained how to install MySQL 8.0 on CentOS 8 and RHEL 8. If you have any questions or feedback, do share it with us in the comment section below.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Anusha Saive
Anusha Saive
Author
About the author

Anusha is an experienced IT professional who worked as a Project Manager and served as a senior writer and editor at Tecmint. A passionate Linux enthusiast, she is also a fitness and travel lover, HYROX athlete, and certified nutrition specialist.

8 Comments

Leave a Reply
  1. The line “systemctl start mysqld” can be removed as the –now in “systemctl enable –now mysqld” will enable and start the process. Otherwise, remove --now as it is redundant.

    Reply
  2. Upstream (from Oracle, the builders of MySQL) the version I saw earlier was more up to date. So it’s fine to pick up the version from RedHat / CentOS but also it may be of interest to follow the upstream repo provided by Oracle for MySQL 8 which gives you a compatible rpm mysql-community-server which is likely to be the true “latest” version.

    RH / CentOS have patched versions and it’s good they provide this out of the box but if you want to be fully up to date using the repo provided by Oracle is probably better (e.g. see: https://downloads.mysql.com/)

    Reply
  3. Hi Anusha, thanks for your article!

    MySQL 8 cannot permit shorthand for creating user and permissions :(

    You have to create before the user:
    CREATE USER ''@'localhost' IDENTIFIED BY '';
    
    and then you can assign the permission:
    GRANT ALL ON .* TO ''@'localhost';
    

    Hope you can help someone :)
    Have fun and stay safe!

    Reply
    • The changes in MySQL 8.0 are deliberate to make user creation/removal/changes explicit and providing grants separately. The older behaviour could generate security issues if you “added grants” to a user that was not configured as this implicitly could create the user.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.