Advance

How to install MySQL on CentOS 8

How to install MySQL on CentOS 8

By the previous articles, you know MySQL is an open-source database management system. In this article, you are going to learn how to install MySQL on CentOS 8. Which is installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack

Prerequisites

The tutorial may be more useful if you know:

  • To set up, follow our initial set up centos 8

 

How to install MySQL on CentOS 8

1- Installing MySQL

You can access to MySQL version 8 on CentOS 8 from the default repositories.

To install the mysql-server package and a number of its dependencies run the command below.

sudo dnf install mysql-server

When you are asked to proceed, press y and then ENTER.

Output
. . .  Install  49 Packages    Total download size: 46 M  Installed size: 252 M  Is this ok [y/N]: y

While the MySQL you have installed till here, is not operational you need to start it with systemctl command.

sudo systemctl start mysqld.service

It’s time to check is the service running correctly or not. So enter the following command.

sudo systemctl status mysqld  

In case of successful starting, you would see below for an active MySQL service.

Output
● 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-03-12 14:07:41 UTC; 1min 7s ago   Main PID: 15723 (mysqld)     Status: "Server is operational"      Tasks: 38 (limit: 5056)     Memory: 474.2M     CGroup: /system.slice/mysqld.service             └─15723 /usr/libexec/mysqld --basedir=/usr    Mar 12 14:07:32 cent-mysql-3 systemd[1]: Starting MySQL 8.0 database server...  Mar 12 14:07:32 cent-mysql-3 mysql-prepare-db-dir[15639]: Initializing MySQL database  Mar 12 14:07:41 cent-mysql-3 systemd[1]: Started MySQL 8.0 database server.

 

You can set MySQL to start whenever the server boots up with command below.

sudo systemctl enable mysqld

Note: If you want to disable MySQL from starting up at boot, use the following command.

sudo systemctl disable mysqld

Now MySQL is installed now.

 

Buy Linux Virtual Private Server

Recommended Article: How to secure Nginx with Let’s Encrypt on Ubuntu 20.04

2- Securing MySQL

The MySQL includes a security script, to use the security script, run the following command.

sudo mysql_secure_installation  

whether you are asked to set up the Validate Password Plugin and you prefer to do that, the script will ask you to choose a password validation level.

Output
Securing the MySQL server deployment.    Connecting to MySQL using a blank password.    VALIDATE PASSWORD COMPONENT can be used to test passwords  and improve security. It checks the strength of password  and allows the users to set only those passwords which are  secure enough. Would you like to setup VALIDATE PASSWORD component?    Press y|Y for Yes, any other key for No: Y    There are three levels of password validation policy:    LOW    Length >= 8  MEDIUM Length >= 8, numeric, mixed case, and special characters  STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file    Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

Then enter and then confirm a secure password.

Output

Please set the password for root here.      New password:     Re-enter new password:

So if you are satisfied with the password you choose from point of strength and security,  enter Y to continue the script:

Output
Estimated strength of the password: 100   Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y

 

3- Testing MySQL

If you want to verify the installation by connecting with the mysqladmin tool, use the command below to connect to MySQL as root.

mysqladmin -u root -p version

The output would be as below:

mysqladmin  Ver 8.0.17 for Linux on x86_64 (Source distribution)  Copyright (c) 2000, 2019, 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.    Server version      8.0.17  Protocol version    10  Connection      Localhost via UNIX socket  UNIX socket     /var/lib/mysql/mysql.sock  Uptime:         2 hours 52 min 37 sec    Threads: 2  Questions: 20  Slow queries: 0  Opens: 131  Flush tables: 3  Open tables: 48  Queries per second avg: 0.001

If you want to add data after connecting to MySQL, run the following command:

mysql -u root -p

Then, you will see the MySQL prompt, when you enter your root MySQL user’s password.

mysql>

From now on, you can begin your MySQL installation and create and load databases.

 

Dear user, we hope you would enjoy this tutorial, you can ask questions about this training in the comments section, or to solve other problems in the field of Eldernode training, refer to the Ask page section and raise your problems in it.

 
View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day