mysql版本:5.7
新安装的mysql数据库,输入mysql后提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决方法:
1.在/etc下找到my.cnf,然后再最后一行添加skip-grant-tables,保存l
2.此时跳过了密码检查,输入mysql可以直接进入。
3.使用mysql数据库,use mysql
4.5.7版本的密码不再是password列,改为了authentication_string,因此更新密码的语句为
update user set authentication_string=PASSWORD("密码") where user='root';
5.修改密码后可能还会报错,执行任何操作可能都会报错:You must reset your password using ALTER USER statement before executing this statement,此时可执行如下语句:alter user user() identified by "新密码";