我在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)
这个错误意味着什么?我该怎么解决呢?
当前回答
Homebrew绝对不会使用标准的重新安装来修复权限,并且追踪哪个文件夹/文件损坏将花费比它值得的更长的时间。
在这种情况下-吹走mysql安装手动和重新安装通过自制。大约需要2分钟。
cd /usr/local/var
Sudo rm -rf mysql
安装mysql
Homebrew默认安装mysql是不安全的,所以如果你想要密码:
mysql_secure_installation
然后点火。
MySQL -uroot
其他回答
我一直回到这篇文章,我已经遇到这个错误好几次了。这可能与在重新安装后导入所有数据库有关。
我用的是自制啤酒。唯一能帮我解决问题的是
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
今天早上,在我的机器决定关闭一夜之后,这个问题又出现了。现在唯一能解决这个问题的就是升级mysql。
brew upgrade mysql
这可能是因为MySQL已经安装但还没有运行。
要验证它正在运行,打开活动监视器,在“所有进程”下,搜索并验证你看到了进程“mysqld”。
你可以通过安装“MySQL.prefPane”来启动它。
以下是帮助我的完整教程: http://obscuredclarity.blogspot.in/2009/08/install-mysql-on-mac-os-x.html
对于我的例子,只需将host指定为127.0.0.1,而不是localhost:
$ bin/mysql -uroot -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
下面我包括了最新的说明从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和我的方式。
对我来说,这就像跑步一样简单:
/usr/local/opt/mysql/bin/mysqld_safe
而不是mysqld