FedoraRHEL Based

How To Install MySQL on Fedora 38

Install MySQL on Fedora 38

In this tutorial, we will show you how to install MySQL on Fedora 38. Before we get started, let’s briefly go over what MySQL is. MySQL is a free, open-source database management system. It’s one of the most popular and widely used options out there, thanks in part to its strong and active community of developers. It’s used in many web applications ranging from small business websites to large enterprise web applications.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MySQL database on a Fedora 38.

Prerequisites

  • A server running one of the following operating systems: Fedora 38.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for MySQL.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install MySQL on Fedora 38

Step 1. Before we can install MySQL on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install MySQL without any issues:

sudo dnf upgrade --refresh

Step 2. Installing MySQL on Fedora 38.

Now proceed to install the latest version of MySQL by running the following command:

sudo dnf install mysql-server

Once MySQL has been installed on your system, start the MySQL service by running the following command in the terminal:

sudo systemctl start mysqld
sudo systemctl enable mysqld

Step 3. Configure MySQL.

By default, MySQL is not secured. You must configure it to make it secure. The following command will secure the MySQL installation by removing unnecessary users, and databases and disallowing remote root login access:

sudo mysql_secure_installation

After successfully installing MySQL and securing it, it’s time to test if it’s working. You can do this by logging in to the MySQL server with the following command:

sudo mysql -u root -p

You will be prompted to enter a password that you created during the secure installation process. If you can log in successfully, that means MySQL is installed and working correctly.

Step 4. Troubleshooting common installation issues for MySQL.

As we install MySQL on Fedora 38, we might encounter a few common installation issues. We’ve compiled a list of these issues and their corresponding solutions.

Error: Cannot establish a connection to MySQL server √

When trying to connect to MySQL, you might see an error message saying that a connection to the MySQL server could not be established. This error is usually caused by one of the following reasons:

  • The MySQL server is not running
  • The hostname or IP address is incorrect
  • The firewall is blocking the connection

To fix the issue, make sure the MySQL server is running by executing the following command:

sudo systemctl start mysqld

Next, verify the hostname or IP address by executing the following command:

mysql -h hostname -u root -p

If there’s still no connection, check if the firewall is blocking the connection by executing the following command:

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reload

Error: MySQL service failed to start √

If you encounter issues with starting the MySQL service, it’s usually caused by one of the following reasons:

  • Wrong MySQL configuration
  • Insufficient disk space
  • MySQL data directory ownership is incorrect

To fix the issue, check the MySQL configuration file (/etc/my.cnf) and make sure it’s configured correctly. Additionally, check the available disk space and free up some space if it’s running low. Finally, ensure that the MySQL data directory is owned by the correct user:

sudo chown -R mysql:mysql /var/lib/mysql/
sudo systemctl start mysqld

Error: Cannot find mysql_config command √

When installing packages that depend on MySQL, you might see an error message saying that the mysql_config command cannot be found. This error is usually caused by the MySQL development package not being installed.

To fix the issue, execute the following command:

sudo dnf install -y mysql-devel

Congratulations! You have successfully installed MySQL. Thanks for using this tutorial for installing the MySQL database on your Fedora 38 system. For additional help or useful information, we recommend you check the official MySQL website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button