A database server is an essential component in most modern software applications. It stores and manages data in a structured way, making it easily accessible to applications and users. In this blog post, we will look at how to set up a database server using MySQL on the Fedora operating system.
Before we start, there are a few prerequisites that we need to have in place:
- A machine running Fedora Linux. We will be using Fedora 34 in this tutorial.
- Access to the command line terminal with root privileges.
- A stable internet connection.
The first step in setting up a database server is to install the MySQL database software. We can do this using the following command:
sudo dnf install mysql-server
This command will download and install the latest version of MySQL available in the Fedora repositories. Once the installation is complete, we need to start the MySQL server by running the following command:
sudo systemctl start mysqld
We can verify that MySQL is running by using the following command:
sudo systemctl status mysqld
If everything is working correctly, we should see a message indicating that the MySQL service is active and running.
By default, MySQL is configured with some security settings that make it inaccessible from the network. We need to modify these settings to allow remote connections to the MySQL server. To do this, we need to edit the MySQL configuration file using the following command:
sudo nano /etc/my.cnf.d/mariadb-server.cnf
Once the file is open, we need to add the following lines to the
bind-address line specifies the IP address that MySQL should bind to. In this case, we are setting it to
0.0.0.0, which means that MySQL will bind to all available network interfaces. The
skip-networking line disables the use of Unix sockets, which is not needed for our purposes.
After making the changes, save the file and exit the editor.
We also need to create a user account that can be used to access the MySQL server from a remote location. We can do this using the following command:
sudo mysql -u root
This command opens the MySQL shell as the root user. Once we are in the shell, we can create a new user account and grant it privileges using the following commands:
CREATE USER 'username'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'; FLUSH PRIVILEGES;
password with the desired values for the new user account.
Once we have made these changes, we need to restart the MySQL server to apply the new settings using the following command:
sudo systemctl restart mysqld
Now that we have set up MySQL, we can access it from a remote location using any MySQL client software. To connect to the server, we need to use the IP address of the machine running MySQL and the credentials for the user account that we created earlier.
In this blog post, we have looked at how to set up a MySQL database server on the Fedora operating system. We started by installing MySQL and configuring it to allow remote connections. We also created a new user account that can be used to access the MySQL server from a remote location. With these steps, we now have a fully functional MySQL database server that can be used to store and manage data for our applications.