1. 更新Linux yum
yum update
2. 安装wget工具
yum install wget
3. 用wget下载MySQL Yum Repository并执行安装
wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
rpm -ivh mysql80-community-release-el7-5.noarch.rpm
4.在线安装MySQL8
yum install -y mysql-server
5.然后去启动mysql服务
systemctl start mysqld
6.查看临时密码登陆mysql,然后修改密码
grep 'temporary password' /var/log/mysqld.log
红色框框内的为临时密码
6.1登陆数据库
mysql -uroot -p临时密码
6.2修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '这里输入密码';
密码格式正确会显示ok,错误会提示报错
7.开启远程登录
use mysql ;
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES;