ySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). SQL is the most popular language for adding, accessing and managing content in a database. It is most noted for its quick processing, proven reliability, ease and flexibility of use.
Install MySQL
To install MySQL by running the following commands.
dnf install @mysql
Output:
[root@vps ~]# dnf install @mysql
Last metadata expiration check: 0:09:24 ago on Thu 25 Feb 2021 12:06:21 PM EST.
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing group/module packages:
mysql-server x86_64 8.0.21-1.module_el8.3.0+2049+47abd494
appstream 22 M
Installing dependencies:
checkpolicy x86_64 2.9-1.el8 baseos 347 k
libaio x86_64 0.3.112-1.el8 baseos 32 k
mariadb-connector-c-config noarch 3.1.11-2.el8_3 appstream 14 k
mecab x86_64 0.996-1.module_el8.3.0+2049+47abd494.9
Start the MySQL service and enable it to automatically start on boot by running the following command.
systemctl enable --now mysqld
systemctl start mysqld
To check the MySQL service by running the following command.
systemctl status mysqld
Output:
[root@vps ~]# systemctl status mysqld
โ mysqld.service - MySQL 8.0 database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pres>
Active: active (running) since Thu 2021-02-25 12:19:01 EST; 16s ago
Process: 7821 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, st>
Process: 7695 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (>
Process: 7670 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, stat>
Main PID: 7777 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 11451)
Memory: 432.1M
CGroup: /system.slice/mysqld.service
โโ7777 /usr/libexec/mysqld --basedir=/usr
Securing MySQL
Finally, you will want to secure your MySQL installation by issuing the following command.
mysql_secure_installation
Output:
[root@vps ~]# mysql_secure_installation
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:
Please set the password for root here.
New password:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
Once secured, you can connect to MySQL and review the existing databases on your database server by using the following command.
mysql -e "SHOW DATABASES;" -p
Output:
[root@vps ~]# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
Done!