问题
MySQL 忘记 root 密码
解决
停止 MySQL
systemctl stop mysql编辑 my.cnf
vim /etc/my.cnf
# 追加
skip-grant-tables
# 保存并推出
:wqroot 身份登录数据库
mysql -uroot -p 设置 root 在本机登录时密码为 root
UPDATE mysql.user SET authentication_string=PASSWORD("root") WHERE user='root' and Host = 'localhost';
flush privileges;
quit;编辑 my.cnf
vim /etc/my.cnf
# 注释/删除
skip-grant-tables
# 保存并退出
:wq启动 MySQL
systemctl start mysql