mac mysql root权限问题_mac上mysql root密码忘记或权限错误的解决办法

常见问题:ERROR 1045: Access denied for user: 'root@localhost' (Using

password: NO)

ERROR 1045: Access denied for user: 'root@localhost' (Using

password: YES)

解决方案 :

重设密码

解决步骤 :

1.关闭数据库方法1.打开mac的系统偏好设置,选择msyql,手动stop

方法2.sudo /usr/local/mysql/support-files/mysql.server stop

2.执行以下命令cd /usr/local/mysql/bin

sudo su

然后在sh-3.2#后输入以下命令./mysqld_safe --skip-grant-tables &

运行结束我们打开mac的系统偏好设置,选择msyql,我们会发现Mysql重新运行了

3.回到终端Command + N 重新打开一个终端执行 mysql -u -root

这时候发现我们已经能进入mysql了,如下Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 12

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

4.重设密码并授权

在mysql> 后运行如下代码create user 'root'@'localhost' identified by 'admin'

grant all privileges on . to root@'localhost'

上面第一个命令我是创建了一个root用户,密码是admin(可输入自己的)

第二个命令是授权

到这一步你就可以用(root,admin)登录mysql了

最后执行下面的终端命令,验证密码是否可以登录$mysql -u root -p

输入刚刚设置的admin这个密码就能进入mysql了作者:码农95贰7

链接:http://www.jianshu.com/p/ecd5e72bb530

來源:简书

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值