yum remove -y mysql
find / -name mysql
1、如果没有安装wget,需要先安装
yum -y install wget
2、获取MySQL8 数据源
wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
3、安装MySQL8数据源
yum -y install mysql80-community-release-el8-1.noarch.rpm
1、检查数据源
yum repolist enabled | grep "mysql.*-community.*"
2、安装过程中可能会出现No match for argument: mysql-community-server,所有要禁用CentOS8自带mysql模块
yum -y module disable mysql
1、安装mysql
yum -y install mysql-community-server
2、启动mysql并设置为自启
systemctl start mysqld && systemctl enable mysqld
1、查看随机密码并使用"mysql -uroot -p"进行登录
grep 'temporary password' /var/log/mysqld.log
2、修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_21root';
3、修改密码策略
SHOW VARIABLES LIKE 'validate_password%';
set global validate_password.length=1;
set global validate_password.policy=0;
3.4 刷新系统权限相关表
flush privileges;
3.5 修改简单的密码(测试用,不推荐生产环境使用过于简单的密码)
1、MySQL8需要先创建权限记录
create user 'root'@'%' identified by '123456';
2、授权
grant all privileges on *.* to 'root'@'%' with grant option;
3、远程访问前必须开放对应端口或者关闭防火墙