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

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,回车输入密码即可。

运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值