1、在线安装MySQL80

1.1、下载并安装mysql

下载地址:https://dev.mysql.com/downloads/repo/yum/
#使用wget下载mysql
wget http://repo.mysql.com/mysql80-community-release-el7.rpm

yum -y install mysql80-community-release-el7.rpm

yum -y install mysql-community-server

1.2、启动并查看状态MySQL

systemctl start  mysqld.service
systemctl status mysqld.service

1.3、查看MySQL默认密码

grep "password" /var/log/mysqld.log

1.4、登录MySQL

mysql -uroot -p

1.5、修改默认密码

MySQL 8.0+ 版本为以下方式:(规则修改)
# 将密码复杂度校验调整简单类型
set global validate_password.policy=0;

# 设置密码最少位数限制为 4 位
set global validate_password.length=4;

MySQL 8.0+ 版本为以下方式:(密码修改)
ALTER USER 'root'@'localhost' IDENTIFIED BY '1234';

1.6、开启远程访问

# 创建用户与权限分配
# 默认的 root 用户只能当前节点localhost访问,是无法远程访问的,我们还需要创建一个新的账户,用于远程访问
在MySQL 8.0中,caching_sha2_password是默认的身份验证插件

# 创建或更新允许 root 用户从任意主机上访问的用户记录
create user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
# 或使用以下命令修改 root 用户的身份验证插件为 mysql_native_password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';

grant all privileges on *.* to 'root'@'%' identified by '1234' with grant option;

flush privileges;

exit