MySQL5.6or5.7登录出错(PS:密码错误)解决方案

札记

Posted by 0xl00se on May 4, 2017

今天,在Linux机器上安装MySQL时出现一个新的问题: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).安装过程也没有设置密码time,登录密码默认也不再为空了,心想可能该MySQL版本改变了密码策略的结果。

经过一番努力之后,发布解决方案:

1.查看/etc/mysql/debian.cn里的debian-sys-maint用户的密码.

2.执行mysql -u debian-sys-maint -p命令,在要求输入密码的地方输入上面的密码.

3.use mysql选中mysql这个数据库.

4.执行update user set authentication_string = password('newpassword'), password_expired = 'N', password_last_changed = now() where user = 'root';命令完成修改root密码。

5.最后 flush privileges;即可。