How to Install MySQL 8.4 LTS on CentOS Stream 9
Install MySQL 8.4 LTS on CentOS Stream 9 using its AppStream module, initialize the server, and configure the service.
On this page
Install MySQL 8.4 LTS from CentOS Stream 9’s mysql:8.4 AppStream module. The steps below verify the server version, start and secure the service, and test a limited application account.
Support status: CentOS Stream 9 is scheduled to reach end of life on May 31, 2027. Plan to migrate before that date and check the CentOS release information for updates.
Version note: CentOS Stream 9 provides the mysql:8.4 AppStream. This procedure explicitly selects that stream instead of relying on a default version.
Prerequisites
Before we proceed with the installation, ensure you have the following prerequisites in place:
-
Access to a CentOS Stream 9 Server: You should have SSH access to a CentOS Stream 9 server. If you don’t have one yet, consider setting up a virtual machine or using a cloud server.
-
Root or Sudo Access: You need root or sudo privileges on the server to install and configure MySQL.
-
Update Your System: Ensure your CentOS Stream 9 system is up to date by running the following command:
sudo dnf update
Step 1: Install MySQL 8.4 LTS
Install the server profile from the CentOS Stream 9 MySQL module:
sudo dnf module install mysql:8.4/server
Check the installed version:
mysql --version
Step 2: Start and Enable MySQL
Start the MySQL service and enable it at boot:
sudo systemctl enable --now mysqld
The initial MySQL root password is written to the error log. Retrieve it with:
sudo grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'
Make a note of this password; you will need it to log in to MySQL in the next step.
Secure the installation by running the interactive script:
sudo mysql_secure_installation
Follow the prompts to configure your MySQL installation’s security settings, including changing the root password if desired.
Step 3: Accessing MySQL
You can access the MySQL shell using the following command:
mysql -u root -p
You will be prompted to enter the root password you obtained in the previous step.
Step 4: Creating a Database and Table
Let’s create a sample database and table within MySQL:
-
After logging in to MySQL, create a new database called
test_db:CREATE DATABASE test_db; -
Switch to the newly created database:
USE test_db; -
Create a sample table, for instance, a simple “users” table:
CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL ); -
You can then verify the table creation using:
SHOW TABLES;
Conclusion
Congratulations! You’ve successfully installed MySQL 8 on your CentOS Stream 9 server, obtained the initial root password, and created a sample database and table. MySQL is a powerful database management system that you can now use to develop applications and manage data effectively. Remember to maintain your MySQL installation by applying updates and adhering to best practices for database security.
If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.