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

http://www.jb51.net/article/77858.htm

http://blog.csdn.net/lgstudyvc/article/details/74999836

 

关闭正在运行的 MySQL :

service mysql stop

禁止:

vim /etc/my.cnf 加入skip-grant-tables

重启

service mysql restart

使用mysql无密码连接server:

mysql -p

更改密码:

update mysql.user set authentication_string=password('123qwe'where user='root' and Host = 'localhost';

*特别提醒注意的一点是,新版的mysql数据库下的user表中已经没有Password字段了

而是将加密后的用户密码存储于authentication_string字段

 

mysql5.7更改密码应该采用命令:

alter user 'root'@'localhost' identified by '123';

这样也可以:

set password for 'root'@'localhost'=password('123');

 

更新一下

mysql> flush privileges;
mysql> quit;
 

修改

vim /etc/my.cnf 去除 skip-grant-tables

 

重启

service mysql restart

然后mysql就可以连接了

 

 

 

 
posted @ 2018-01-18 17:31  忘忧般若汤  阅读(224)  评论(0编辑  收藏  举报