How to install and Configure Mysql Server 8 on Fedora 34/35

MySQL is an open-source relational database management system. Its one of the popular relational management system.

Mysql is commonly installed as part of the popular LAMP or LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. It implements the relational model and Structured Query Language (SQL) to manage and query data.

In this guide we are going to install mysql 8 on Fedora 34/35

# Table of Content

  1. Ensuring the server is Up to date
  2. Installing Mysql 8 server
  3. Starting and enabling mysql service
  4. Securing mysql installation
  5. Testing mysql installation

# Ensuring the Server is Up to date

Before proceeding, let us ensure that our Fedora server is up to date. Use this command to update the server packages:

sudo dnf -y update

# Installing Mysql 8 server

Now that our packages are updated, we can proceed to install mysql server. Use this command to search the package on the server that provides mysql server.

$ sudo dnf search mysql-server
Last metadata expiration check: 2:06:28 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
========================================================================================= Name Matched: mysql-server ==========================================================================================
community-mysql-server.x86_64 : The MySQL server and related files

Use this command to check the info of the listed package to confirm that it provides the mysql version that we want:

$ sudo dnf info community-mysql-server
Last metadata expiration check: 2:12:13 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
Installed Packages
Name         : community-mysql-server
Version      : 8.0.26
Release      : 1.fc34
Architecture : x86_64
Size         : 106 M
Source       : community-mysql-8.0.26-1.fc34.src.rpm
Repository   : @System
From repo    : updates
Summary      : The MySQL server and related files
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MySQL server and some accompanying files and directories.

Now install using this command:

sudo dnf install -y community-mysql-server

Once installed, verify the installation using this command:

$ rpm -qi community-mysql-server
Name        : community-mysql-server
Version     : 8.0.26
Release     : 1.fc34
Architecture: x86_64
Install Date: Sun 31 Oct 2021 08:28:55 AM UTC
Group       : Unspecified
Size        : 111652520
License     : GPLv2 with exceptions and LGPLv2 and BSD
Signature   : RSA/SHA256, Tue 17 Aug 2021 04:01:38 PM UTC, Key ID 1161ae6945719a39
Source RPM  : community-mysql-8.0.26-1.fc34.src.rpm
Build Date  : Wed 11 Aug 2021 09:34:44 PM UTC
Build Host  : buildvm-x86-18.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mysql.com
Bug URL     : https://bugz.fedoraproject.org/community-mysql
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

#

Starting and enabling mysql service {.wp-block-heading}

Up to this point we managed to install the mysql service in our system. The service will not be started by default, so we will have to start by issuing the following command:

sudo systemctl start mysqld

To enable the service to start on reboots, use this command:

$ sudo systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.

Now check the status of the service to confirm that it is actually running:

$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2021-10-31 08:37:07 UTC; 1min 21s ago
   Main PID: 55677 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 4603)
     Memory: 449.0M
        CPU: 3.328s
     CGroup: /system.slice/mysqld.service
             └─55677 /usr/libexec/mysqld --basedir=/usr

Oct 31 08:36:58 new-cloud systemd[1]: Starting MySQL 8.0 database server...
Oct 31 08:36:58 new-cloud mysql-prepare-db-dir[55597]: Initializing MySQL database
Oct 31 08:37:07 new-cloud systemd[1]: Started MySQL 8.0 database server.

The Active: active (running) since ... indicates that the service is up and running.

To view the MySQL 8 service log as follows using the journalctl command:

$ sudo journalctl -u mysqld -xe
$ sudo tail -f /var/log/mysql/mysqld.log

# Securing mysql installation

MySQL includes a security script that allows you to change some default configuration options in order to improve MySQL’s security.

To use the security script, run the following command:

sudo mysql_secure_installation

This will take you through a series of prompts asking if you want to make certain changes to your MySQL installation’s security options. These options include:

  • setting up root user password
  • enabling the VALIDATE PASSWORD COMPONENT that ensures strong passwords are used
  • Removing anonymous users
  • Disabling root to login remotely
  • Removing test databases

Here is a sample output from my server:

$ sudo 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: 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
Please set the password for root here.

New password:

Re-enter new password:

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
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!

#

Testing MySQL Installation {.wp-block-heading}

Let us check mysql version with this command:

$ mysql -V
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Now you can Login as the root user and the password specified above.

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.26    |
+-----------+
1 row in set (0.00 sec)

# Conclusion

In this article, we managed to install and test mysql 8 installation on Fedora 34/35

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy