In this article we will learn How to install MYSQL 8 on centos 8. MYSQL is an open-source database management system. It implements the relational model and Structured Query Language (SQL) to manage and query data.
Install MySQL 8 :
Run the following command to install the mysql-server package and its dependencies:
sudo dnf install mysql-server
MySQL is installed on CentOS 8 server but it isn’t yet operational. The package we installed configures MySQL to run as a systemd service named mysqld.service.In order to use MySQL, we will need to start it with the systemctl command as shown below:
systemctl start mysqld.service
To check that the service is running correctly, run the following command:
systemctl status mysqld
Next, we will set MySQL to start whenever the server boots up; run the following command to do so:
systemctl enable mysqld
MySQL is now installed, running, and enabled on CentOS 8 server. Next, we will configure your database’s security using a shell script that came preinstalled with your MySQL instance.
To use the security script, run the following command:
This will take you to a series of prompts asking if you want to make changes to your MySQL installation’s security options. The first prompt will ask whether you would like to enable the Validate Password Plugin, which you can use to test the strength of your MySQL password.
If you elect to set up the Validate Password Plugin, the script will ask you to choose a password validation level. The strongest level — which you select by entering 2 will require your password to be at least eight characters long and include a mix of uppercase, lowercase, numeric, and special characters and for the rest of options you still have to set an 8 character password including uppercase, lowercase and numeric characters:
Regardless of whether you choose to set up the Validate Password Plugin, the next prompt will be to set a password for the MySQL root user. Enter and then confirm a secure password of your choice:
Now press Y to confirm with your given password, then press Y on all the prompts that followed after setting password.
Now, you have installed and secured MySQL on your CentOS 8 server. As a final step, we will test that the database is accessible and working as expected.
You can verify your installation and get information about it by connecting with the mysqladmin tool, a client that lets you run administrative commands to MYSQL server. Use the following command to connect to MySQL as root user to verify installation version.
mysqladmin -u root -p version
As it can be seen in above picture we have successfully installed MYSQL 8.
If you want to connect to MYSQL server to create databases and handle your data. Use the following command to connect with MYSQL.
mysql -u root -p
Now a prompt will appear asking for a password that was set while securing MYSQL. Provide the password and then you will enter in the MYSQL.
Now, you can start using your MySQL to create and load databases and start running queries as per your need.