Download and Extract
1## Download the compressed package
2wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.39-1.el8.x86_64.rpm-bundle.tar
3## Upload to the server
4scp mysql-8.0.39-1.el8.x86_64.rpm-bundle.tar root@your-server:/root
5## Move to the specified directory
6mv mysql-8.0.39-1.el8.x86_64.rpm-bundle.tar /opt
7## Extract
8cd /opt
9tar -xvf mysql-8.0.39-1.el8.x86_64.rpm-bundle.tar
After extraction, the following files will be available
1mysql-community-client-8.0.39-1.el8.x86_64.rpm
2mysql-community-server-8.0.39-1.el8.x86_64.rpm
3mysql-community-libs-8.0.39-1.el8.x86_64.rpm
4mysql-community-common-8.0.39-1.el8.x86_64.rpm
5mysql-community-client-plugins-8.0.39-1.el8.x86_64.rpm
6mysql-community-icu-data-files-8.0.39-1.el8.x86_64.rpm
Uninstall the system-installed MariaDB (if present)
1rpm -qa | grep mariadb
2yum remove -y mariadb*
Install in dependency order
1cd /opt
2rpm -ivh mysql-community-common-8.0.39-1.el8.x86_64.rpm
3rpm -ivh mysql-community-client-plugins-8.0.39-1.el8.x86_64.rpm
4rpm -ivh mysql-community-libs-8.0.39-1.el8.x86_64.rpm
5rpm -ivh mysql-community-client-8.0.39-1.el8.x86_64.rpm
6rpm -ivh mysql-community-icu-data-files-8.0.39-1.el8.x86_64.rpm
7rpm -ivh mysql-community-server-8.0.39-1.el8.x86_64.rpm
Start and enable on boot
1systemctl enable mysqld
2systemctl start mysqld
3systemctl status mysqld
Retrieve the initial root password
1grep 'temporary password' /var/log/mysqld.log
The output will be similar to
1A temporary password is generated for root@localhost: Abcde!12345
Login and change the password
1mysql -uroot -p
1ALTER USER 'root'@'localhost' IDENTIFIED BY 'StrongPass@2025';
Set up remote access (optional)
1CREATE USER 'root'@'%' IDENTIFIED BY 'StrongPass@2025';
2GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
3FLUSH PRIVILEGES;
Open firewall port (if remote connection is needed)
1firewall-cmd --permanent --add-port=3306/tcp
2firewall-cmd --reload
Verification
1systemctl status mysqld
2mysql -uroot -pStrongPass@2025 -e "SELECT VERSION();"
3netstat -tulnp | grep 3306
Quick uninstall command (if reinstalling)
1systemctl stop mysqld
2rpm -qa | grep mysql | xargs rpm -e --nodeps
3rm -rf /var/lib/mysql /var/log/mysqld.log /etc/my.cnf
Optional: Custom data directory
1mkdir -p /data/mysql
2chown -R mysql:mysql /data/mysql
3vim /etc/my.cnf
Add or modify
1[mysqld]
2datadir=/data/mysql
3socket=/var/lib/mysql/mysql.sock
4symbolic-links=0
5log-error=/var/log/mysqld.log
6pid-file=/var/run/mysqld/mysqld.pid
Then restart
1systemctl restart mysqld
Summary Recommendations
| Item | Recommended Method |
|---|---|
| General Platform | tar.gz Binary Package |
| RHEL/CentOS | RPM Bundle |
| Ubuntu/Debian | .deb Package (apt install ./xxx.deb) |
| Offline Machines | scp or USB copy package + manual dependency installation |
| Data Directory | /data/mysql or /var/lib/mysql |
| Service Start | systemctl / mysql.server either one |