Mysql 5.7密码过期修改密码

今天在运行项目的时候出现:“Your password has expired. To log in you must change it using a client that supports expired passwords”这个错误,自己一看才知道是数据库密码过期引起的,这也导致了navicat等工具链接并打不开数据库,唯一的途径只能是修改数据库密码啦!

自己摸索了一早上,在网上也找了好几种方法来解决,最便捷也最好的方法是用命令来修改密码:

1.找到自己mysql安装的路径,如:C:\Program Files\MySQL\MySQL Server 5.7\bin

2.打开命令窗口:cmd 并进入mysql安装的目录bin文件夹下

C:\>cd Program Files\MySQL\MySQL Server 5.7\bin

3.先用之前的密码登陆mysql后台

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecur
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.5-m15-log
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

4.进入mysql后你的所有操作都不会被成功执行,提示如下:

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

5.上面的提示让你必须修改了密码才能进行后续的操作,现在用命令修改密码:

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

6.当成功执行上面的sql语句,证明你的mysql密码修改成功,即你可以用新的密码来使用数据库啦

猜你喜欢

转载自blog.csdn.net/u012365843/article/details/48436641