我在Mac Lion和homebrew install mysql
上安装了MySQL,但当我尝试mysql -u root
时,我得到了以下错误:
错误2002 (HY000):无法通过套接字'/tmp/mysql.sock‘连接到本地MySQL服务器(2)
这个错误是什么意思?我怎么才能修复它?
发布于 2021-12-29 17:44:45
在我的mac m1 macOS蒙特利上安装了MySQL后,使用brew install mysql
我得到了以下信息:
[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.
还有这条警告:
Warning: The post-install step did not complete successfully You can
try again using: brew postinstall mysql
之后,我尝试使用brew services start mysql
启动MySQL,得到以下错误
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2)
我设法用以下命令修复了它:
> rm -rf ~/opt/homebrew/var/mysql/
> brew postinstall mysql
现在您可以使用mysql -uroot
或mysql -uroot -p
进行连接。
https://stackoverflow.com/questions/15450091
复制相似问题