Centos7 offline installation of MySQL 8

Time:2021-11-19
  1. Download the MySQL 8 installation package from the official website(https://dev.mysql.com/downloa…
    Centos7 offline installation of MySQL 8
  2. Upload the downloaded installation package to the server
    Centos7 offline installation of MySQL 8
  3. Delete the original MySQL and MariaDB
rpm -qa|grep mysql
rpm -qa|grep mariadb

Centos7 offline installation of MySQL 8

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

Centos7 offline installation of MySQL 8

  1. Unzip MySQL installation package
tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar

The following files are generated after decompression
Centos7 offline installation of MySQL 8

  1. 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
  1. View service status
systemctl status mysqld

Centos7 offline installation of MySQL 8

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/
  1. Start MySQL service
systemctl start mysqld

View the status of MySQL service at this time:

systemctl status mysqld

Centos7 offline installation of MySQL 8

MySQL started!

  1. Modify MySQL login

Get temporary password

grep 'temporary password' /var/log/mysqld.log

Centos7 offline installation of MySQL 8

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.