MySQL is the most popular open-source relational database management system.
MySQL was initially developed by MYSQL AB, now owned by Oracle Corporation. It was the primary database application on Linux until MariaDB, a fork of MySQL, came into the picture.
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.
In this article, we will see go through steps on how to install MySQL 8.0 on CentOS 8 / RHEL 8.
MySQL 8.0 Enhancements
RHEL 8 is distributed with MySQL 8.0 which has the following new features:
- Enhanced JSON functionality.
- MySQL 8.0 has support for roles. Roles are collections of privileges.
- It incorporates a transactional data dictionary, which stores information about database objects.
- Has support for common table expressions – recursive and nonrecursive
- Support for window functions, which perform a calculation for each row from a query, using related rows.
- It comes with InnoDB which support NOWAIT and SKIP LOCKED options with locking read statements.
Install MySQL 8.0 on CentOS8 and RHEL 8
Install the MySQL 8.0 server by using the CentOS package manager as root or user with sudo privileges:
# sudo dnf install @mysql
The @mysql module installs MySQL and all dependencies.
Once the installation is complete, start the MySQL service and enable it to automatically start on boot by running the following command:
# systemctl start mysqld # systemctl enable --now mysqld
# systemctl status mysqld
● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2019-22-12 06:07:35 UTC; 1min 59s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 4633 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 4708 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 9584) Memory: 496.4M CGroup: /system.slice/mysqld.service └─4708 /usr/sbin/mysqld Dec 22 06:07:23 centos8 systemd: Starting MySQL Server... Dec 22 06:07:35 centos8 systemd: Started MySQL Server.
Secure MySQL 8 server
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.
You 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.
To interact with the MySQL server from the command line, use the MySQL client utility, which is installed as a dependency. Test the root access by typing:
# mysql -u root -p
Enter the root password when prompted, and you will be presented with the MySQL shell as shown below:
Enter password: << Enter MySQL Root Password Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.13 Source distribution Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
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.
See also: Backup and Restore MySql (MariaDB) database using mysqldump