背景
centos7,mysql8.0.27
问题
利用skip-grant-tables重置root密码,执行命令
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xx';
报错ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@‘localhost’,密码重置失败。
解决办法
update user set authentication_string = '' where user='root' ;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xx';
如果遇到:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
执行
flush privileges;