How to Install MySQL 8.4 LTS on Oracle Linux 9
Install MySQL 8.4 LTS on Oracle Linux 9.6 or later from its AppStream module, then initialize the database and start the service.
On this page
MySQL 8 is a major MySQL series that includes features such as common table expressions, window functions, atomic DDL, and JSON functions.
In this tutorial, we will install MySQL 8 on Oracle Linux 9 from the default repositories.
Oracle Linux 9.6 and later provide the mysql:8.4 AppStream module. This procedure selects that stream explicitly; check the Application Stream lifecycle table.
Prerequisites
Before you install MySQL, you need:
- Oracle Linux 9 fresh installation
- Non-root user with sudo privileges
- Internet connection
Step 1 - Install MySQL 8.4 LTS
Install the MySQL 8.4 server module:
sudo dnf module install mysql:8.4
This selects the MySQL 8.4 stream and its server profile.
Step 2 - Verify the Installed Version
Check the installed MySQL version:
mysql --version
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:
-- Run as an administrator before logging in with the application account.
CREATE DATABASE IF NOT EXISTS mytestdb;
-- MySQL 8.0.18+ returns a generated password; save it securely for the connection test.
CREATE USER 'myuser'@'localhost' IDENTIFIED BY RANDOM PASSWORD;
-- CREATE is included for the sample table; use a separate migration account for schema changes in production.
GRANT CREATE, SELECT, INSERT, UPDATE, DELETE ON mytestdb.* TO 'myuser'@'localhost';
Step 6 - Test MySQL
Connect to the MySQL shell:
mysql -u myuser -p
SHOW DATABASES;
Step 7 - Create a Sample Table
Create a table in the sample database:
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 9 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.