您的位置:首页 > 数据库 > MySQL

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

2018-01-18 17:31 495 查看
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'
);


更新一下

修改

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

重启

service mysql restart

然后mysql就可以连接了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: