- Download the MySQL 8 installation package from the official website(https://dev.mysql.com/downloa…)
- Upload the downloaded installation package to the server
- Delete the original MySQL and MariaDB
rpm -qa|grep mysql
rpm -qa|grep mariadb
rpm -e --nodeps mysql-community-libs
rpm -e --nodeps mysql-community-server
rpm -e --nodeps mysql-community-client
rpm -e --nodeps mysql-community-common
rpm -e --nodeps mysql-community-client-plugins
rpm -e --nodeps mariadb
- Unzip MySQL installation package
tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
The following files are generated after decompression
- Install RPM packages one by one and pay attention to the installation sequence
rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm
- View service status
systemctl status mysqld
At this time, MySQL service has not been started. First perform database initialization and enter the following command:
mysqld --initialize --console
Sublicense Directory:
chown -R mysql:mysql /var/lib/mysql/
- Start MySQL service
systemctl start mysqld
View the status of MySQL service at this time:
systemctl status mysqld
MySQL started!
- Modify MySQL login
Get temporary password
grep 'temporary password' /var/log/mysqld.log
Copy the temporary password, then log in to MySQL, copy the temporary password, and then log in to MySQL
mysql -uroot -p
Change Password:
Alter user 'root' @'localhost 'identified by' new password ';
Refresh permissions:
flush privileges;
Now you can log in with your new password.