How to Install MySQL on Fedora?
MySQL is one of the oldest and most reliable open-source (Available to all) Relational Database Management Systems. It is Trusted by millions of users worldwide for developing various web-based software Applications. MySQL, along with its fork MariaDB, is available on almost all operating systems and supports a variety of platforms. However, make sure you install either MySQL or MariaDB, as their packages conflict with each other.
In this article, we will explain the process of installing MySQL on Fedora in detail, from updating system packages to verifying the installation and securing MySQL. If we are new to Fedora or MySQL, don’t worry we will keep it simple and technical.
Why Choose MySQL on Fedora?
Fedora is a cutting-edge, open-source Linux distribution known for its stability, performance, and commitment to providing the latest software and technologies. It is widely used by developers and system administrators for its balance of innovation and reliability. MySQL on Fedora is a popular choice due to the following reasons:
- High Performance: MySQL offers lightning-fast query execution and can handle heavy workloads efficiently.
- Security: Fedora provides timely security updates, and MySQL’s robust security model ensures data integrity.
- Scalability: MySQL is highly scalable, handling both small-scale applications and large enterprise systems.
Steps to Install MySQL in Fedora
Step 1: Update fedora packages/releases.
Before installing any package make sure we have updated our all repositories and apply all updates (if any). Fedora Linux uses dnf as a primary package manager. To update repositories type the below command into your terminal:
sudo dnf update
-(1).png)
Command Explain: dnf is a software package manager that installs, updates, and removes packages on fedora. Here dnf update command will check all your dependencies and update them. Once dependencies get updated we can proceed to the installation part.
Step 2: Install MySQL Community Server
Now run the following command in your terminal to install the Mysql Community server in your system. It will also install all other required dependencies.
sudo dnf install community-mysql-server -y
-(1).png)
dnf is slower than apt and Pacman package manager, so take a cup of tea and have patience. It will take some time.
Additional: Cross-check MySQL services using systemctl
To cross-check or verify, whether MYSQL was installed correctly or not using,
systemctl status mysqld
-(1).png)
Basically systemctl utility is used to start or stop any system services. It can also use for checking the status of services. In our case, it will check mysqld service status. Another way to check MySQL installation status is by pasting the below command in the terminal,
mysql - -version
-(1).png)
To auto-start MYSQL on each boot of our Linux Machine, use the below command,
sudo systemctl enable mysqld
-(1).png)
Step 3: MySQL Secure Installation.
The default installation password is weak, even MySQL can start without any password and hackers can easily hack our database. So it is always advisable to do a secure installation of MySQL. For that type of Terminal,
sudo mysql_secure_installation
-(1).png)
After this, it will start with a blank password. Now our task is to validate Password, for doing this press Y/y.
-(1).png)
There are 3 levels of password Validation. Recommended 1 (Medium) means your password should contain capital case, lowercase, a number, and a Special symbol. It's not mandatory, we can select 2 or 0 instead of 1.
-(1).png)
After password validation, this will ask for some permissions including Removing anonymous users, disabling the temporary passwords, and reloading tables. For secure installation answer all of them with 'y' or 'Y'.
.jpg)
Great all set, Mysql installation part is done.
Starting MySQL in Fedora
After secure installation (STEP -3) we created a password for the root user. Now we are going to login MySQL server with root privilege using,
mysql -u root -p
.png)
You’ll be prompted to enter the root password that you set during the secure installation process.
Creating and Managing MySQL Users
For better security and management, it’s a good idea to create new MySQL users (other than root).
1. To create a user (other than root) copy the below query in your MySql Shell.
CREATE USER 'your_userName'@'localhost' IDENTIFIED BY 'Password';
-(1).png)
2. Instead of your_userName, you have to type your UserName and your password. Now, Grant all permissions to the newly created users.
GRANT ALL PRIVILEGES ON *.* TO 'your_userName'@'localhost';
-(1).png)
3. Instead of "deepUser" enter "your_userName". To enter in deepUser type,
mysql -u deepUser -p
-(1).png)
Update MySQL in Fedora Linux
To update MySQL in Fedora Linux paste the command in the terminal,
sudo dnf update mysql-server
-(1).png)
Uninstall MySQL in Fedora Linux
To uninstall completely MySQL server paste the below command into the terminal,
sudo dnf remove mysql mysql-server
-(1).png)
This was all about the installation part of MySQL in Fedora. In case anyone has some issues during installation feel free to ask in the comment section. Upvote/Like the solution if it helps you.
Conclusion
Installing MySQL on Fedora is straightforward and easy, thanks to the dnf package manager. By following the above steps, you’ve installed MySQL, secured it, and created your first database! Whether you’re using it for web development, data analysis, or enterprise-level applications, MySQL's speed, flexibility, and security make it an excellent choice for managing your data. By following these detailed steps, you'll be able to install MySQL on Fedora and start building powerful, data-driven applications.