How to Install MySQL 8 on Oracle Linux 8
MySQL is one of the most popular open source database management systems. In this tutorial, we will show you how to install MySQL 8 on Oracle Linux 8.
MySQL 8 is the latest major version upgrade of MySQL. It comes with many new features and improvements such as better performance, new SQL functions, new JSON data type support, atomic DDL statements, invisible indexes, etc.
In this tutorial, we will install MySQL 8 on Oracle Linux 8 from the default repositories.
Prerequisites
Before you install MySQL, you need:
- Oracle Linux 8 fresh installation
- Non-root user with sudo privileges
- Internet connection
Step 1 - Enable MySQL 8 Repository
Enable the MySQL 8 repository:
sudo dnf module enable mysql -y
This will enable the community MySQL 8.0 modules.
Step 2 - Install MySQL
Install MySQL server:
sudo dnf install @mysql -y
This will install MySQL 8.0 on your Oracle Linux system.
Step 3 - Start MySQL Service
Start the MySQL service:
sudo systemctl start mysqld
Step 4 - Secure the MySQL Installation
Run the mysql_secure_installation script:
sudo mysql_secure_installation
This will set the root password, remove anonymous users etc.
Step 5 - Create MySQL User
Create a dedicated MySQL user for your applications:
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'localhost';
Step 6 - Test MySQL
Connect to the MySQL shell:
mysql -u myuser -p
SHOW DATABASES;
Step 7 - Create Sample Database
Create a test database:
CREATE DATABASE mytestdb;
USE mytestdb;
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(50)
);
MySQL is now installed and ready to use!
Conclusion
We have demonstrated how to install MySQL 8 on Oracle Linux 8 from the default repositories. You can now use MySQL for your database applications on Oracle Linux.
If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.