How To Install MySQL 8 On CentOS Stream 9 (Step-by-Step Guide for Beginners)
Assuming you are using CentOS Stream 9 (or a similar RHEL 9-based system), here is step-by-step instructions how to install MySQL 8.
By default, CentOS ships with MariaDB (a MySQL-compatible fork), but you can install official MySQL 8.0 from Oracle's Yum repository.
1. Download the official MySQL Yum repository package :
sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm -y
2. Enable the MySQL 8.0 module and disable default MySQL modules :
sudo dnf module disable mysql -y
sudo dnf install mysql-community-server -y
3. Start and enable MySQL :
sudo systemctl start mysqld
sudo systemctl enable mysqld
4. Get the temporary MySQL root password :
sudo grep 'temporary password' /var/log/mysqld.log
5. Secure your MySQL installation :
sudo mysql_secure_installation
- Use the temporary password.
- Choose a strong new root password.
- Follow prompts to remove anonymous users, disable remote root login, and remove test databases.
6. Log in to MySQL :
mysql -u root -p
7. Verify installation :
You can check the installed MySQL version :
mysql --version
Note on Firewalls (Optional)
If you're accessing MySQL remotely :
sudo firewall-cmd --permanent --add-service=mysql
sudo firewall-cmd --reload
Tags :