Mac连接mysql error 1045

Mac 版本10.11

mysql 版本 5.7

1. 首先 从 偏好设置-mysql 停止mysql服务器 运行


2. 然后新建一个终端中,打开 mysql/bin 所在位置, 本机为:

cd /usr/local/mysql/bin

3. 运行一个deamon进程,使能够跳过权限检查:

sudo ./mysqld_safe --skip-grant-tables
4. 另新建一个终端并输入如下命令,更新用户root的密码:
$ mysql

mysql> use mysql;

mysql> UPDATE user SET password=PASSWORD('YOUR_NEW_PASSWORD_HERE') WHERE user = 'root';

mysql> exit;
注意以上命令红色字段,如果是mysql v5.6及以前版本,则字段名为 password,
		如果是mysql v5.7,table里面并没有password此字段,会得到错误提示:
		ERROR 1054 (42S22): Unknown column 'password' in 'field list'
		在v5.7中,password字段名为:authentication_string,则应输入:
		update user set authentication_string=password('1111') where user='root';

5. kill刚才的deamon进程,并且 在偏好设置-mysql中开启mysql服务

6. 在终端中输入: mysql -u root -p 即可解决问题。

Ref: 1. http://stackoverflow.com/questions/13480170/access-denied-for-mysql-error-1045

2. http://stackoverflow.com/questions/30692812/mysql-user-db-does-not-have-password-columns-installing-mysql-on-osx/31122246#31122246

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值