• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install MySQL on CentOS 8

Written by Admin, Updated On January 1, 2020
centos, mysql
How to Install MySQL on CentOS 8

MySQL is free and open-source relational database management system which is used widely. You can host multiple database and users on a single MySQL Server. In this guide, we will help you to install and secure MySQL 8.0 on CentOS 8 systems.

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.

You can also install MariaDB 10.3 database version from the default repository, which is “drop-in replacement” for MySQL 5.7, with some limitations. You can install MariaDB 10.3 if your application is not compatible with MySQL 8.0.

Install MySQL 8.0 on CentOS 8#

The MySQL 8.0 is available in default repository on CentOS 8 systems. You can install MySQL 8.0 server using package manager with root or user with sudo privileges. Run the below command:

sudo yum install @mysql

The @mysql module will install latest MySQL and all dependencies.

Once the installation is finish then start the MySQL service and enable it to start it automatically on boot. Run below command:

sudo systemctl start mysqld
sudo systemctl enable --now mysqld

Check the status of MySQL by running following command:

sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
    Active: active (running) since Thu 2020-01-01 22:14:19 UTC; 49s ago

Securing & Configuring MySQL#

MySQL includes a default security script which will improve security of MySQL installation. By this script it will make changes in default options like remote root logins and sample users and test database. Run the following security script:

sudo mysql_secure_installation

You will be prompted to enter your root user password of MySQL and also it will ask to set new root password. The password needs to be at least eight characters long and to contain at least one uppercase letter, one lowercase letter, one number, and one special character.

The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:

After that, it will prompt few more questions. For all next questions press Y and hit Enter key for each. By this it will remove anonymous users, test database, disable remote root logins and load these new rules so that MySQL immediately respects the changes you have made.

Testing MySQL#

We can connect MySQL via command line using MySQL client which is installed a dependency of the MySQL server package. You can login to MySQL using following command as root user :

sudo mysql -uroot -p

It will prompt to enter the root password which you have previously set. Once you will enter password it will be shown output as following :

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.17 Source distribution

Conclusion#

In this guide, We show you how to install and secure a MySQL 8.0 server on a CentOS 8 system.

If you have any suggestion or questions, please leave comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Apache on CentOS 8
Next Article   How to Install PHP on CentOS 8

Related Posts

  • [Solved] Unknown collation: utf8mb4_0900_ai_ci

    [Solved] Unknown collation: utf8mb4_0900_ai_ci

    June 29, 2021
  • How to Install Php 8 on CentOS 8

    How to Install PHP 8 on CentOS 8

    January 27, 2021
  • How to Install Python 3.9 on CentOS 8

    How to Install Python 3.9 on CentOS 8

    December 31, 2020

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook