connect to server at 'localhost' failed

2025-05-06 16:56:49

1、先停止MySQL服务打开“系统偏好设置”,选择“MySQL”,在打开的对话框中点击“Stop MySQL Server”

connect to server at 'localhost' failed

2、打开终端,输入命令:sudo/usr/local/mysql/bin/mysqld_safe --user=mysql --sk足毂忍珩ip-grant-tables --skip-networking &--skip-grant-tables:不启动grant-tables(授权表),跳过权限控制。--skip-networking :跳过TCP/IP协议,只在本机访问(这个选项不是必须的。可以不用)

connect to server at 'localhost' failed

4、查询MySQL的用户信息,输入SQL命令:select host,user,authentication_string from user;这一步骤熟悉的人可以跳过,在mysql 5.7以前的版本,密码列的英文名是password,但是在5.7版本改成了authentication_string,这点是需要注意的。

connect to server at 'localhost' failed

6、新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效

connect to server at 'localhost' failed
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢