我在Mac OS X Mountain Lion上安装了MySQL,但当我尝试MySQL -u root时,我得到了以下错误:
错误2002 (HY000):无法通过套接字/tmp/ MySQL连接到本地MySQL服务器。袜子”(2)
这个错误意味着什么?我该怎么解决呢?
我在Mac OS X Mountain Lion上安装了MySQL,但当我尝试MySQL -u root时,我得到了以下错误:
错误2002 (HY000):无法通过套接字/tmp/ MySQL连接到本地MySQL服务器。袜子”(2)
这个错误意味着什么?我该怎么解决呢?
当前回答
在尝试了许多解决方案之后,似乎最终成功的是通过IP连接。不再文件套接字被随机删除。
只需更新MySQL客户端配置(例如/usr/local/etc/my.cnf):
[client]
port = 3306
host=127.0.0.1
protocol=tcp
其他回答
下面我包括了最新的说明从brew安装mysql,以便更新搜索这个问题可以受益:
$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.6.26.yosemite.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring mysql-5.6.26.yosemite.bottle.1.tar.gz
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
在我的情况下,我现在通过launchctl load加载mysql ~/Library/LaunchAgents/homebrew.mx .mysql。Plist,然后能够启动$ mysql和我的方式。
只有这一点让我成功了 酿造服务启动——全部启动 (试完所有答案后)
我建议你去跑步
mysql.server start
在去之前
mysql -u root -p
为了确保mysql服务器在登录之前正在运行
当你启动/重启一台没有运行mysql服务器的机器时,这种情况会发生很多次。
卸载MySQL。 删除/usr/local/var/mysql/. 安装MySQL。
没有工作。我只是重新安装mysql(不要担心你的数据保持不变)。
然后开始使用
sudo mysql.server start
这是所有。酿造服务mysql启动不启动mysql。
MacOS Monterey上。