1、systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
2、systemctl restart mysqld
3、输入mysql后可直接登录
4、mysql> alter user 'root'@'localhost' identified by 'xxxxxxx';
mysql>flush privileges;
mysql> alter user 'root'@'localhost' identified by 'xxxxx';
退出登录
5、恢复密码登录
systemctl set-environment MYSQLD_OPTS=""
systemctl restart mysqld
或者
reboot
systemctl show-environment 查看MYSQLD_OPTS
分享:
网友评论