How to install and secure MySQL server on REDHAT 8.5
To Install and secure MySQL in RedHat 8.5
Introduction
mysql_secure_installation is a shell script that enables a secure MySQL server installation on Unix systems. The script configures security settings and allows to: Set a password for root accounts.
Step 1: Check the installed version OS by using the below command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.5 (Ootpa)"
Step 2: Install MySQL Server by using the below command
[root@linuxhelp ~]# yum install mysql-server*
Updating Subscription Management repositories.
AppStream 254 MB/s | 7.2 MB 00:00
BaseOS 122 MB/s | 2.4 MB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repo
Size
================================================================================
Installing:
mysql-server x86_64 8.0.26-1.module+el8.4.0+12359+b8928c02 1 25 M
Installing dependencies:
mariadb-connector-c-config
Is this ok [y/N]: y
Downloading Packages:
(1/7): mariadb-connector-c-config-3.1.11-2.el8_ 363 kB/s | 15 kB 00:00
(7/7): protobuf-lite-3.5.0-13.el8.x86_64.rpm 15 MB/s | 149 kB 00:00
--------------------------------------------------------------------------------
Total 189 MB/s | 38 MB 00:00
Complete!
Step 3: Enable MySQL services by using the below command
[root@linuxhelp ~]# systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
Step 4: Start MySQL services by using the below command
[root@linuxhelp ~]# systemctl start mysqld
Step 5: Login MySQL as a root user to check whether contains password or not by using the below command
[root@linuxhelp ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Step 6: If there is no password simply quit It by using the below command
mysql> \q
Bye
Step 7: Make MySQL server Secure by using the below command
[root@linuxhelp ~]# mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
Press y|Y for Yes, any other key for No: y
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.
Step 8: Enter your favorite password
New password:
Step 9: Re-enter your favorite same password
Re-enter new password:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
All done!
Step 10: Now login MySQL with password by using the below command
[root@linuxhelp ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Step 11: Quit MySQL by using the below command
mysql>\q
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to install and secure MySQL in RedHat 8.5.Your feedback is much welcome.