美文网首页
Ubuntu 重置MySQL Root密码

Ubuntu 重置MySQL Root密码

作者: Pengx | 来源:发表于2016-08-29 16:11 被阅读1228次

环境

Ubuntu 16.04 i386

1.停止MySQL服务

$ service mysql stop

2.跳过认证启动MySQL服务

$ mysqld_safe --skip-grant-tables

3.免密码登录MySQL

$ mysql -u root
mysql> use mysql;

MySQL 5.7 以前版本

mysql> update user set Password=PASSWORD('new_password') where user='root';

MySQL 5.7 以后版本(Password字段改为了authentication_string)

mysql> update user set authentication_string=PASSWORD('new_password') where user='root';
mysql> flush privileges;
mysql> exit;

4.开启MySQL服务

$ service mysql start

5.使用刚刚重置的新密码登录

$ mysql -u root -p 

相关文章

网友评论

      本文标题:Ubuntu 重置MySQL Root密码

      本文链接:https://www.haomeiwen.com/subject/pogxettx.html