首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误2002 (HY000):无法通过套接字'/tmp/mysql.sock‘连接到本地MySQL服务器

错误2002 (HY000):无法通过套接字'/tmp/mysql.sock‘连接到本地MySQL服务器
EN

Stack Overflow用户
提问于 2013-03-16 21:53:14
回答 38查看 400.1K关注 0票数 252

我在Mac Lion和homebrew install mysql上安装了MySQL,但当我尝试mysql -u root时,我得到了以下错误:

错误2002 (HY000):无法通过套接字'/tmp/mysql.sock‘连接到本地MySQL服务器(2)

这个错误是什么意思?我怎么才能修复它?

EN

Stack Overflow用户

发布于 2021-12-29 17:44:45

在我的mac m1 macOS蒙特利上安装了MySQL后,使用brew install mysql我得到了以下信息:

代码语言:javascript
运行
复制
[System] [MY-013169] [Server] /opt/homebrew/Cellar/mysql/8.0.27_1/bin/mysqld (mysqld 8.0.27) initializing of server in progress as process 3624

[ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.

[ERROR] [MY-013236] [Server] The designated data directory /opt/homebrew/var/mysql/ is unusable. You can remove all files that the server added to it.

[ERROR] [MY-010119] [Server] Aborting

[System] [MY-010910] [Server] /opt/homebrew/Cellar/mysql/8.0.27_1/bin/mysqld: Shutdown complete (mysqld 8.0.27)  Homebrew.

还有这条警告:

代码语言:javascript
运行
复制
Warning: The post-install step did not complete successfully You can
try again using:   brew postinstall mysql

之后,我尝试使用brew services start mysql启动MySQL,得到以下错误

代码语言:javascript
运行
复制
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2)

我设法用以下命令修复了它:

代码语言:javascript
运行
复制
> rm -rf ~/opt/homebrew/var/mysql/
> brew postinstall mysql

现在您可以使用mysql -urootmysql -uroot -p进行连接。

票数 0
EN
查看全部 38 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15450091

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档