Home / How To / How to install MySQL 8 database server on CentOS 8

How to install MySQL 8 database server on CentOS 8



MySQL is a free, open source and one of the most popular database systems around the world. It is a relational database management platform run by Oracle Cloud. It uses structured query language to add, access, and manage content in a database. It is known for its proven reliability, fast machining, ease of use and flexibility. There are several new features added to MySQL 8 including, JSON support, Transactionional Data Dictionary, Persistent runtime configuration, Document Store, Optimizer Tips, SQL roles, CTEs and Window features, Invisible index and many more.

Note : Before installing MySQL 8, refer to the official documentation as MySQL 8 has some new features and changes that made some applications incompatible with this version.

In this tutorial, we will show you how to install MySQL 8 database on CentOS 8 server.

Prerequisites

  • A server running CentOS 8.
  • A root password is set on your server.

Installing MySQL 8.0 from MySQL Repository

By default, MySQL 8.0 is not available in the CentOS 8 repository. So you need to install the MySQL 8.0 community archive in your system. You can install it with the following command:

  rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1
.noarch.rpmebrit19659010??You should see the following output:

  Downloading https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
warning: /var/tmp/rpm-tmp.hF0m5V: Header V3 DSA / SHA1 Signature, Key ID 5072e1f5: NOKEY
Verifying ... ################################ [100%]
Preparing ... ################################ [100%]
Updating / installing ...
1: mysql80-community-release-el8-1 ################################ [100%]

Next, verify if The MySQL 8.0 layer is enabled or not with the following command:

  dnf repolist all | grip mysql | grip enabled 

You should see the following output:

  CentOS-8 - AppStream 3.1 MB / s | 6.5 MB 00:02
CentOS-8 - Base 3.0 MB / s | 5.0 MB 00:01
CentOS-8 - Extras 5.3 kB / s | 2.1 kB 00:00
MySQL 8.0 Community Server 24 MB / s | 543 kB 00:00
MySQL Connectors Community 1.9 MB / s | 19 kB 00:00
MySQL Tools Community 677 kB / s | 62 kB 00:00
mysql-connectors-community MySQL Connectors Community enabled: 42
mysql-tools-community MySQL Tools Community enabled: 19
mysql80 community MySQL 8.0 Community Server enabled: 31

Then temporarily disable the AppStream archive and install the latest version of MySQL 8.0 from the MySQL community repository with the following command:

  dnf --disablerepo = AppStream install mysql-community-server-y 

Once the installation is complete, you can verify the installed version of MySQL with the following command:

  mysql -Version 

You should see the following output:

  mysql Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

Then start MySQL service and enable it after system startup with the following command:

  systemctl start mysqld 
systemctl enable mysqld

You can also check the status of MySQL with the following command:

  systemctl status mysqld [19659013] You would see the following output: 

? mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor setting: disabled)
Active: active (running) since Thu 2020-03-05 09:37:46 EST; 12 years ago
Document: man: mysqld (8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3244 ExecStartPre = / usr / bin / mysqld_pre_systemd (code = terminated, status = 0 / SUCCESS)
Main PID: 3329 (mysqld)
Status: "Server is running"
Details: 39 (limit: 12537)
Memory: 587.7M
CGroup: /system.slice/mysqld.service
?? 3329 / usr / sbin / mysqld

March 05 09:37:01 centos8 systemd [1]: Start MySQL Server ...
March 05 09:37:46 centos8 systemd [1]: Started MySQL Server.

Then it is always a good idea to run mysql_secure_installation scripts to enable some additional security features including, setting a new MySQL root password, removing anonymous users and disabling remote login.

First find the MySQL default password the following command:

  cat /var/log/mysqld.log | grep -i & # 39; temporary password & # 39; 

Output:

  2020-03-05T14: 37: 40.273796Z 5 [Note] [MY-010454] [Server]   A temporary password is generated for [email protected]: GN2uNx-vPqwS

Note the above password and change it with the mysql_secure_install script.

  mysql_secure_installation 

Answer all the questions below:

  Secure MySQL server installation.

Enter User Root Password: Enter your temporary MySQL root password

The existing user account password has expired. Enter a new password.

New password: Enter a new root password

Enter new password: Enter new root password
The "validate_password" component is installed on the server.
The following steps are run with the existing configuration
of the component.
Use existing root password.

The estimated strength of the password: 100
Do you want to change the root password? ((Press y | Y for Yes, any other button for No): N Type N and Enter to continue

... skip.
By default, a MySQL installation has an anonymous user,
which allows anyone to log in to MySQL without having to
a user account created for them. This is only intended for
testing and to make the installation a little smoother.
You should remove them before moving to a production
environment.

Delete anonymous users? (Press y | Y for Yes, any other button for No): Y
Success.


Normally, root should only be allowed to connect from
& # 39; local host & # 39 ;. This ensures that no one can guess
the root password from the network.

Remove root login remotely? (Press y | Y for Yes, any other button for No): Y
Success.

By default, MySQL comes with a database called & # 39; test & # 39; as
anyone can access. This is also for testing only,
and should be removed before moving into a production
environment.


Delete the test database and access it? (Press y | Y for Yes, any other button for No): Y
- Losing test database ...
Success.

- Remove permissions in the test database ...
Success.

If you reload the permission tables, everyone will change
so far it will take effect immediately.

Reload privilege tables now? (Press y | Y for Yes, any other button for No): Y
Success.

All ready!

Install MySQL 8.0 from AppStream Repository

You can also install MySQL 8.0 from the default AppStream archive on CentOS 8. You can install it with the following command:

  dnf install @mysql -y 

When the installation is done, check the version of MySQL with the following command:

  mysql -Version 

You should see the following output:

  mysql Ver 8.0.17 for Linux on x86_64 (Source Distribution)

Then you start the MySQL service and enable it to start after restarting the system with the following command:

  systemctl start mysqld 
systemctl enable mysqld

By default, MySQL root password is not set in CentoS 8 So you must set it with the mysql_secure_installation script.

  mysql_secure_installation 

Answer all questions shown below:

  Secure installation of MySQL server.

Connect to MySQL with a blank password.

VALIDATED PASSWORD COMPONENT can be used to test passwords
and improve safety. It checks the strength of the password
and allows users to set only the passwords
sure enough. Do you want to set VALIDATE PASSWORD component?

Press y | Y for Yes, any other button for No: Y

There are three levels of password validation policy:

LOW Length> = 8
MEDIUM Length> = 8, numeric, mixed and special characters
STRENGTH Length> = 8, numeric, mixed letter, special characters and dictionary file

Enter 0 = LOW, 1 = MEDIUM and 2 = STRENGTH: 0
Enter the root password here.

New password:

Re-enter new password:

The estimated strength of the password: 100
Do you want to continue with the specified password? (Press y | Y for Yes, any other button for No): Y
By default, a MySQL installation has an anonymous user,
which allows anyone to log in to MySQL without having to
a user account created for them. This is only intended for
testing and to make the installation a little smoother.
You should remove them before moving to a production
environment.

Delete anonymous users? (Press y | Y for Yes, any other button for No): Y
Success.


Normally, root should only be allowed to connect from
& # 39; local host & # 39 ;. This ensures that no one can guess
the root password from the network.

Remove root login remotely? (Press y | Y for Yes, any other button for No): Y
Success.

By default, MySQL comes with a database called & # 39; test & # 39; as
anyone can access. This is also for testing only,
and should be removed before moving into a production
environment.


Delete the test database and access it? (Press y | Y for Yes, any other button for No): Y
- Losing test database ...
Success.

- Remove permissions in the test database ...
Success.

If you reload the permission tables, everyone will change
which has been made so far will take effect immediately.

Reload privilege tables now? (Press y | Y for Yes, any other button for No): Y
Success.

All ready!

Conclusion

In the guide above you learned how to install MySQL 8 from the MySQL community repository and from the AppStream repository on CentOS 8. You can now start creating a new database and database user.


Source link