MySQL 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.
To install MySQL by running the following commands.
dnf install mysql mysql-server
[root@server ~]# dnf install mysql mysql-server AlmaLinux 9.0-beta - BaseOS 7.7 kB/s | 3.9 kB 00:00 AlmaLinux 9.0-beta - AppStream 7.5 kB/s | 3.9 kB 00:00 AlmaLinux 9.0-beta - Extras packages 7.6 kB/s | 3.8 kB 00:00 Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mysql x86_64 8.0.22-7.el9 appstream 2.6 M mysql-server x86_64 8.0.22-7.el9 appstream 16 M Installing dependencies: checkpolicy x86_64 3.3-1.el9 appstream 339 k libaio x86_64 0.3.111-13.el9 baseos 23 k libevent x86_64 2.1.12-6.el9 baseos 261 k libicu x86_64 67.1-9.el9 baseos 9.6 M libtirpc x86_64 1.3.2-1.el9 baseos 93 k mariadb-connector-c-config noarch 3.2.6-1.el9_0 appstream 9.7 k mecab x86_64 0.996-3.el9.3 appstream 348 k mysql-common x86_64 8.0.22-7.el9 appstream 79 k mysql-errmsg x86_64 8.0.22-7.el9 appstream 444 k
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
[root@server ~]# systemctl status mysqld ● mysqld.service - MySQL 8.0 database server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor pr> Active: active (running) since Tue 2022-05-24 16:00:01 CEST; 26s ago Process: 2493 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, st> Process: 2515 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service> Main PID: 2592 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 5912) Memory: 404.3M CPU: 5.284s CGroup: /system.slice/mysqld.service └─2592 /usr/libexec/mysqld --basedir=/usr
Finally, you will want to secure your MySQL installation by issuing the following command.
[root@server ~]# 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: Re-enter new password: By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. 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
[root@server ~]# mysql -e "SHOW DATABASES;" -p Enter password: +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+