MYSQL8.0.12 版本修改ROOT密码

环境:cento 7
mysql 8.0.12
成功部署完毕后出现故障情况:

  1. 正常启动MYSQL服务后,敲Linux中root账户和密码进入不去。
  2. 从/etc/my.cnf 配置文件中加入skip-grant-table后正常登陆,但是不能创建用户等操作

总结来说:
想进去mysql后不能操作多指令,操作指令又不能进去mysql,死循环

挖坑环节:
网上找了很多办法,首先加入skip-grant-table.后进去刷新权限表,重启服务,不用密码的root进去,在改root密码后,重新刷新权限表。方法试了很多个都不对。修改root环节始终不对。
python3 的坑 让我想到mysql8会不会也是抛弃向下兼容,更改了一些东西

先来个正确步骤:
1
systemctl stop mysqld
2
修改my.cnf
添加 skip-grant-table
保存退出
3
systemctl start mysql
4
mysql
进入数据库
use mysql;
5
update user set authentication_string=‘’ where user=‘root’;
6
flush privileges;
exit
7
vim /etc/my.conf
注释 skip-grant-table
systemctl restart network
这样就可以了

之前用的update user set password=password(‘123456’) where user=‘root’;
已经无法使用 password 字段已经改成了authentication_string字段

猜你喜欢

转载自blog.csdn.net/xueyubingfeng1/article/details/81737496