记一次重置mysql8密码的操作
- 停止服务
1 | service mysqld stop or systemctl stop mysqld.service |
- 启动服务,不检查授权表
1 | mysqld --skip-grant-tables --skip-networking & |
报错:
sock 权限问题
1 | sudo chown -R mysql:mysql /var/lib/mysql/ |
- 执行重置
1 | alter user 'root'@'localhost' IDENTIFIED BY '123456'; |
都失败
Operation ALTER USER failed for ‘root‘@’localhost’
Operation CREATE USER failed for ‘root‘@’localhost’
先执行flush privileges
仍然失败,可能是因为用户已经被删除了,再删除一次
drop user ‘root‘@’localhost’;
create user ‘root‘@’localhost’ identified by ‘123456’;
提示密码不符合规则
1 | SHOW VARIABLES LIKE 'validate_password%'; |
flush 一下
1
flush privileges
重启
1
service mysqld restart
记一次重置mysql8密码的操作