错误信息为:Access denied for user 'root'@'localhost' (using password: YES)
解决方法:
第一步:苹果->系统偏好设置(最下面)->MySQL,关闭mysql服务
第二步:
进入终端
输入(cd /usr/local/mysql/bin/)回车
输入(sudo su)回车以获取管理员权限
输入(./mysqld_safe --skip-grant-tables &)回车以禁止mysql验证功能,mysql会自动重启,偏好设置中的mysql状态会变成running
第三步:
新建一个终端窗口(cmd+T),
输入命令(./mysql)回车
输入命令(flush privileges;)分号别忘记输了
网上教程输入(set password for 'root'@'localhost' = password('123456');)会提示错误
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
后续解决方案:
输入命令(alter user 'root'@'localhost' identified by '新密码';) 也是有分号
显示成功,这样密码就修改成功了,可以登入了
网友评论