Mysql5.7及以上系列 连接出现Access denied for user 'root'@'localhost' (using password: YES)

1、苹果->系统偏好设置->最下面点mysql,关闭mysql服务

2、进入终端输入

cd /usr/local/mysql/bin/

3、获取管理员权限

sudo su

4.禁止mysql验证功能,mysql会自动重启,偏好设置中的mysql状态会变成running

./mysqld_safe --skip-grant-tables &

5、进入命令行

./mysql

5、修改密码:Mysql5.7以上password改为了authentication_string(分号别忘记输了)

update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';
6、刷新修改(分号别忘记输了)
flush privileges;

猜你喜欢

转载自blog.csdn.net/oJueQiang123456/article/details/79815763