CentOS / Ubuntu下 软件安装教程

Mysql5.7忘记root密码及mysql5.7修改root密

2016-08-29  本文已影响1405人  技术学习

这篇文章主要介绍了Mysql5.7忘记root密码及mysql5.7修改root密码的方法的相关资料,需要的朋友可以参考下

mysql 5.7 不再支持skip-grant-tables配置

  1. 关闭正在运行的 MySQL
[root@localhost ~] service mysqld stop
[root@localhost ~] mysqld_safe --skip-grant-tables &

以安全模式运行MySQL(禁止远程连接)

[root@localhost ~] mysqld_safe --skip-grant-tables --skip-networking &
[root@localhost ~] mysql
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
mysql> flush privileges;
mysql> quit;

特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了,而是将加密后的用户密码存储于authentication_string字段

root@localhost ~]# service mysql restart

然后mysql就可以连接了,但此时操作似乎功能不完全,还要alter user…

mysql>alter user 'root'@'localhost' identified by '123';
上一篇 下一篇

猜你喜欢

热点阅读