MySQL is a free database management system commonly used in web applications to store and retrieve records and information. It was initially developed by MYSQL AB, now owned by Oracle Corporation.
MySQL was the primary database in Linux operating system until MariaDB, a fork of MySQL, came into the picture.
Here, we will see how to install MySQL 8.0 on Fedora 35 / Fedora 34.
Add MySQL Repository
First, add MySQL’s official repository to install the MySQL community server.
# Fedora 35 sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc35-1.noarch.rpm # Fedora 34 sudo rpm -ivh https://dev.mysql.com/get/mysql80-community-release-fc34-2.noarch.rpm
Then, check if the MySQL repository is enabled by using the following command.
sudo dnf repolist all | grep mysql | grep enabled
Output:
mysql-connectors-community MySQL Connectors Community enabled mysql-tools-community MySQL Tools Community enabled mysql80-community MySQL 8.0 Community Server enabled
Install MySQL Community Server
Install MySQL 8.0
After adding the repository, use the dnf
command in to install the MySQL community server 8.0.
sudo dnf install -y mysql-community-server
Install MySQL 5.7
After the installation of the MySQL server, you can start the service using the following command.
sudo systemctl start mysqld
Then, enable MySQL service at system startup.
sudo systemctl enable mysqld
Finally, verify the status of the MySQL server using the following command.
sudo systemctl status mysqld
Initial MySQL Root Password
In Fedora, you can find the initial MySQL root password in /var/log/mysqld.log
. You can use the below command to get the initial password from the log file.
sudo cat /var/log/mysqld.log | grep -i 'temporary password'
Output:
2021-11-27T07:52:26.014940Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: mSa1,T_!xPyp
Secure MySQL server
Now, you need to run mysql_secure_installation
to secure your MySQL installation. This command takes care of setting the root password, removing anonymous users, disallowing root login remotely, etc.
sudo mysql_secure_installation
Output:
Securing the MySQL server deployment. Enter password for user root: << Enter the initital MySQL root password The existing password for the user account root has expired. Please set a new password. New password: << Enter new MySQL root password Re-enter new password: << Re-enter new MySQL root password The 'validate_password' component is installed on the server. The subsequent steps will run with the existing configuration of the component. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : N << Type N as we have already set new password ... skipping. 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 << Type Y to remove anonymous users 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 << Type Y to disallow root login remotely 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 << Type Y to remove test database - 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 << Type Y to reload privilege tables Success. All done!
Work with MySQL Server
Now, you can use the mysql
command to log in to MySQL server and perform the desired activities.
mysql -u root -p
Output:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 8.0.27 MySQL Community Server - GPL 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>
Conclusion
That’s All. I hope you have learned how to install MySQL 8.0 on Fedora 35 / Fedora 34.