centos7 (Linux 7) install mysql 8

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

Insert picture description here
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

Insert picture description here
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
Insert picture description here
will generate a temporary password after initialization is complete
Insert picture description here
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';

Insert picture description here
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

Guess you like

Origin blog.csdn.net/u013202238/article/details/113754910