MySQL错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

来源:互联网 发布:知乎日本长寿 编辑:程序博客网 时间:2024/05/16 12:24

From terminal I enter(终端输入):

mysql -u root

which outputs this error(输出错误为):

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

To try and resolve it I stopped mysql from ‘System Preferences’, then from terminal typed:(为了解决这个问题,从‘System Perferences’结束mysql)

sudo mysqld_safe —skip-grant-tables

I opened a second tab and entered(再一次启动mysql):

mysql -u root

Then from in mysql(显示):

update mysql.user set password_expired = 'N', authentication_string=PASSWORD('newpassword') where user = 'root';

解决办法:
For security reason mysql -u root want work untill you pass -p in command so try with below way.(由于安全原因,mysql -u root在遇到pass -p的时候才能开始工作)

 mysql -u root -p[Enter] //enter your localhost password

所以,在终端输入上述命令,mysql -u root -p,回车输入密码即可。

运行

阅读全文
0 0