1.下载mysql源
wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
2.安装源
yum install -y mysql80-community-release-el8-1.noarch.rpm
3.检查源
yum repolist enabled | grep "mysql.*-community.*"
4.禁用CentOS8自带mysql模块
yum module disable -y mysql
5.安装mysql服务
yum install -y mysql-community-server
6.启动服务
systemctl start mysqld
7.查看服务状态
systemctl status mysqld
8.获取临时密码
grep 'temporary password' /var/log/mysqld.log
9.登录控制台
mysql -u root -p
password
10.重置密码
(大写字母、小写字母、数字、特殊字符)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'New_Password_123';
11.修改权限
use mysql;
update user set host='%' where user='root';
flush privileges;
12.创建用户
create user 'root'@'%' identified with mysql_native_password by 'NewPassword'; //1、先创建权限记录
或 create user 'root'@'%' identified by 'NewPassword';
grant all privileges on *.* to 'root'@'%' with grant option; //2、授权
flush privileges;
网友评论