MySQL8.0修改密码的正确姿势分享

前言

mysql 更新完密码,总是拒绝连接、登录失败?mysql8.0 不能通过直接修改 mysql.user 表来更改密码。正确更改密码的方式备注: 清空root密码

mysql8.0 不能通过直接修改 mysql.user 表来更改密码。

因为authentication_string字段下只能是mysql加密后的43位字符串密码,其他的导致错误。错误不报出,但是无法再登录mysql,总是会提示 无法认证。

参考:mysql8.0

mysql 5.7.9 之后取消了password 函数,authentication_string=password(“123456”) 会报错

c:\windows\system32>mysql -u root -p
enter password: ******
error 1045 (28000): access denied for user ‘root’@‘localhost’ (using password: yes)
1234567891011121314

如果 你已经这样更改密码,并且导致了无法进入mysql。本人表示同情之时,还为了你提供了详细的解决方案。请查看本文备注:清空root 密码

正确更改密码的方式

  • 备注: 清空root密码

停止 mysql 任务 net stop mysql

mysqld 命令 mysqld –console –skip-grant-tables –shared-memory

无密码进入mysql mysql -u root

清空root 密码 update user set authentication_string=”” where user=“root”;

另一个终端无密码进入

停止 mysqld 任务,ctrl+c 结束任务,或者直接关闭 运行 mysqld 的 cmd 终端。

需要先停止运行上述 mysqld 任务,否则报错

f:\mysql\mysql-8.0.13-winx64\bin>net start mysql
mysql 服务正在启动 .
mysql 服务无法启动。

服务没有报告任何错误。

请键入 net helpmsg 3534 以获得更多的帮助。

先停止上述 mysqld 任务

f:\mysql\mysql-8.0.13-winx64\bin>net start mysql
mysql 服务正在启动 …
mysql 服务已经启动成功。

现在 mysql root 已经没有了密码

f:\mysql\mysql-8.0.13-winx64\bin>mysql -u root -p
enter password:
welcome to the mysql monitor.  commands end with ; or \g.


type ‘help;’ or ‘\h’ for help. type ‘\c’ to clear the current input statement.

mysql>

总结

到此这篇关于mysql8.0修改密码的正确姿势的文章就介绍到这了,更多相关mysql8.0修改密码姿势内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐