找到 MySQL 配置文件 mysqld.cnf
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf在文件中找到 skip-external-locking,在它的下一行添加:
skip-grant-tables
保存退出文件,重启 MySQL
输入命令 mysql,进入MySQL (只需要在命令行下输入mysql就行)
修改root密码
刷新权限,退出 MySQL
这时你的MySQL密码已经重置完成了,把刚才添加的那条 skip-grant-tables 命令删除,不然对下次 MySQL 启动会有影响。
等等,壮士请留步,给个赞啦,生活不宜,写博客不宜啊。