MySQL5.7出现Your password has expired. To log in you must change it using a client that supports expir

今天晚上本来想写bootstrap-fileinput插件集成fastdfs的文章,但是刚启动idea里面的QiYuAdmin就出现了错误: 
Your password has expired. To log in you must change it using a client that supports expired passwords.其实只需要修改密码就可以了,这个问题我找到了以下解决办法:

1、修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1

这一行配置让 mysqld 启动时不对密码进行验证

2、重启 mysqld 服务:systemctl restart mysqld

3、使用 root 用户登录到 mysql:mysql -u root

4、切换到mysql数据库,更新 user 表:

update mysql.user set authentication_string=password(‘root’) where user=’root’ and Host = ‘localhost’;

flush privileges;

在之前的版本中,密码字段的字段名是 password,5.7版本改为了 authentication_string

5、退出 mysql,编辑 /etc/my.cnf 文件,删除 skip-grant-tables=1 的内容

6、重启 mysqld 服务,再用新密码登录。但此时还是不行哦,我以为可以了,就没有往下看了。其实还有最后一步。

7、alter user ‘root’@’localhost’ identified by ‘root’;

有个疑问,不知道为什么程序是一直链接不上的,但是客户端,比如Navcat和MySQL的WorkBench都是可以链接上的?最后一段我是直接在Navcat里面执行的

原文地址:https://www.cnblogs.com/wangmo/p/8360104.html