如何在 CentOS8 上安装 MYSQL8

执行如下命令依次安装 common,lib,client,server

tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar

rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force

rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force

查看 mysql 的安装包

rpm -qa | grep mysql

mysql 数据库的初始化和相关配置


mysqld --initialize;

chown mysql:mysql /var/lib/mysql -R;

systemctl start mysqld.service;

systemctl enable mysqld;

查看刚刚初始化的数据库密码

cat /var/log/mysqld.log | grep password

登入数据库

mysql -uroot -p

重设密码 root 密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
flush privileges;

创建远程访问用户

create user 'resin'@'%' identified with mysql_native_password by 'Fxz03&80&67yjP';
grant all privileges on *.* to 'resin'@'%' with grant option;
flush privileges;