Download the installation package through wget
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar
Unzip
tar -xvf mysql-8.0.23-1.el7.x86_64.rpm-bundle.tar
Execute the following commands in order to install
rpm -ivh mysql-community-common-8.0.23-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.23-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.23-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.23-1.el7.x86_64.rpm --nodeps --force
Execute the following command to initialize the database:
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;
You may encounter the following abnormal
mysqld: error while loading shared libraries: libaio.so.1: can not open shared object file: No such file or directory
Solution : Run the following command to install yum install -y libaio
will generate a temporary password after initialization is complete
using the default password generated , Log in to the database and change it to a new password
mysql -uroot -p
Modify the local root account login password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root666';
Set up root account remote access
mysql> create user 'root'@'%' identified with mysql_native_password by 'pwd123456';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit;
Reference: https://blog.csdn.net/weixin_42266606/article/details/80879571