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