MySQL 8 is a powerful and widely used open-source relational database management system. Installing MySQL 8 on Oracle Linux 8 requires following specific steps to ensure a successful setup. This guide outlines the process of installing and configuring MySQL 8 on Oracle Linux 8.
Prerequisites
Before proceeding with the installation, ensure that the following requirements are met:
- A system running Oracle Linux 8.
- Root or sudo privileges to install packages.
- Stable internet connection for downloading MySQL packages.
Step 1: Enable MySQL Yum Repository
By default, MySQL is not included in the Oracle Linux repositories. The first step is to enable the MySQL Yum repository.
sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm -y
Once the repository is installed, verify that MySQL 8 is available:
sudo dnf repolist | grep mysql
Step 2: Install MySQL 8
With the repository enabled, install MySQL 8 using the following command:
sudo dnf install mysql-community-server -y
This will install MySQL along with its dependencies. To verify the installed version, run:
mysql --version

Step 3: Start and Enable MySQL Service
Once MySQL is installed, start the service and enable it to launch at boot.
sudo systemctl start mysqld sudo systemctl enable mysqld
To check the status of MySQL, use:
sudo systemctl status mysqld
Step 4: Secure MySQL Installation
After installation, it is essential to configure MySQL securely using the mysql_secure_installation script.
sudo mysql_secure_installation
During this process, follow these steps:
- Retrieve the temporary root password with:
sudo grep "temporary password" /var/log/mysqld.log
- Enter the temporary password and set a new strong password.
- Remove anonymous users.
- Disable remote root login if not needed.
- Remove the test database.
- Reload privilege tables.
After completing these steps, MySQL will be properly secured.
Step 5: Login to MySQL
To access MySQL, use the following command:
mysql -u root -p
Enter the root password set during the security configuration to access the MySQL shell.

Step 6: Configure Firewall (If Applicable)
If a firewall is running on Oracle Linux 8, open the MySQL port (3306) to allow remote connections.
sudo firewall-cmd --permanent --add-service=mysql sudo firewall-cmd --reload
To verify that MySQL is accessible remotely, check its listening ports:
sudo ss -tulnp | grep mysqld
Troubleshooting
If any issues arise during installation, check the MySQL logs with:
sudo journalctl -u mysqld --no-pager | tail -50
Additionally, verify installed packages:
rpm -qa | grep mysql
Conclusion
Installing MySQL 8 on Oracle Linux 8 is a straightforward process when following these steps. By enabling the official Yum repository, installing the necessary packages, securing the installation, and configuring system settings as needed, MySQL 8 can be set up efficiently and securely.
FAQ
1. How do I check if MySQL is installed on Oracle Linux 8?
Run the following command to check the installed version:
mysql --version
2. What is the default MySQL root password?
After installation, MySQL sets a temporary password, which can be retrieved using:
sudo grep "temporary password" /var/log/mysqld.log
3. How do I restart MySQL if needed?
Use the following command:
sudo systemctl restart mysqld
4. How can I allow remote connections to MySQL?
Modify the MySQL configuration file /etc/my.cnf and change the bind address:
bind-address=0.0.0.0
Restart MySQL after making changes:
sudo systemctl restart mysqld
5. Is MySQL 8 compatible with Oracle Linux 8?
Yes, MySQL 8 is fully compatible with Oracle Linux 8 and can be installed using the official Yum repository.