今天,在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;
即可。