Mac&Mysql问题记录

1. 系统偏好设置无法关闭服务

停止服务:

sudo /usr/local/mysql/support-files/mysql.server stop

启动服务:

sudo /usr/local/MySQL/support-files/mysql.server start

重启服务:

sudo /usr/local/mysql/support-files/mysql.server restart

2. 终端连接报错ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

2.1 关闭mysql服务
2.2 进入终端
  1. 终端进入: cd /usr/local/mysql/bin/ 回车
  2. 登陆管理员权限: sudo su回车后输入管理员密码
  3. 输入以下命令来禁止mysql验证功能 ./mysqld_safe --skip-grant-tables &
    回车后mysql会自动重启(偏好设置中mysql的状态会变成running)
  4. 输入命令以后./mysql 回车
  5. 设置一个新的密码SET PASSWORD FOR 'root@localhost'=(你的新密码) ; (最后有一个分号)
    此时会可能出现另外一个报错:ERROR 1290 (HY000):The MySQL server is running with the–skip-grant-tablesoption。输入下面命令
flush privileges;

然后再次输入命令修改密码,可能会再次出现问题:ERROR 1133 (42000): Can‘t find any matching row in the user table。执行下面命令

1. use mysql;
2. select Host,User from user;

在这里插入图片描述
那么需要增加用户的操作:

create user 'root'@'%' identified by '123456';

然后我们再来查询 mysql.user 的记录,可以发现有了 ‘root’@‘%’ 这条记录 :
在这里插入图片描述
然后更新权限:

flush privileges;

grant all privileges on *.* to 'root'@'%'

然后输入修改密码命令继续报错:corresponds to your MySQL server version for the right syntax to use near ‘password(‘123456’)’ at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘password(‘123456’)’ at line 1

接着执行下面命令:
查看mysql版本:select version();
在这里插入图片描述

接着执行:alter user 'root'@'localhost' identified by '123456';
mysql> alter user ‘root’@‘localhost’ identified by ‘123456’;
Query OK, 0 rows affected (0.01 sec)

  1. 重新打开一个终端进行测试:
    在这里插入图片描述

  2. 输入exit

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值