微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 尝试了所有仍然得到ERROR 2002(HY000)的东西:无法通过socket’/tmp/mysql.sock'(2)连接到本地MySQL服务器

每次我运行xampp并尝试运行$ mysql -u root -p时,它抛出的错误是:
ERROR 2002(HY000):无法通过套接字’/tmp/MysqL.sock’连接到本地 MySQL服务器(2)

我在mac OS-10.9中使用xampp 1.7.3版.启动Apache和MysqL不是问题,我已经确认apache已经开始进入活动监视器. ![在此处输入图像说明] [1]

我尝试的几件事情:
1)通过在终端中绑定此命令来检查MysqL是否正在运行:MysqLadmin -u root -p status
结果是:MysqLadmin:在’localhost’连接到服务器失败
错误:’无法通过套接字连接到本地MysqL服务器’/tmp/MysqL.sock'(2)’
检查MysqLd是否正在运行,并且套接字:’/ tmp / MysqL.sock’存在!

2)我检查并在/var/MysqL/MysqL.sock’中找到了MysqL.sock文件.

可能引发此错误但无法说出错误的事情:
1)我最近将我的操作系统从Mountain Lion升级到Mavricks.
2)我还安装了单独的MysqL来处理rails上的ruby.我已经确定该版本已关闭.

没有解决这个问题,我无法在本地进行任何开发,并且在PHP脚本中连接MysqL似乎是不可能的.所以任何帮助将不胜感激.

这是来自/ applications / xampp / xamppfiles / logs / error_log的error_log文件

[Sat Nov 02 09:56:31 2013] [notice] caught SIGTERM,shutting down
[Sat Nov 02 09:56:39 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 02 09:56:40 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Nov 02 09:56:40 2013] [notice] Digest: done
[Sat Nov 02 09:56:40 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Sat Nov 02 12:55:47 2013] [notice] caught SIGTERM,shutting down
[Sat Nov 02 13:40:16 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 02 13:40:18 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Nov 02 13:40:18 2013] [notice] Digest: done
[Sat Nov 02 13:40:18 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Sat Nov 02 15:12:39 2013] [notice] caught SIGTERM,shutting down
[Sat Nov 02 20:54:41 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 02 20:54:43 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Nov 02 20:54:43 2013] [notice] Digest: done
[Sat Nov 02 20:54:44 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Sat Nov 02 21:10:53 2013] [notice] caught SIGTERM,shutting down
[Sat Nov 02 21:10:57 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 02 21:10:58 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Nov 02 21:10:58 2013] [notice] Digest: done
[Sat Nov 02 21:10:58 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Sat Nov 02 21:31:39 2013] [notice] caught SIGTERM,shutting down
[Sat Nov 02 21:31:44 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 02 21:31:47 2013] [notice] Digest: generating secret for digest authentication ...
[Sat Nov 02 21:31:47 2013] [notice] Digest: done
[Sat Nov 02 21:31:47 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Sat Nov 02 21:45:07 2013] [notice] caught SIGTERM,shutting down
[Sun Nov 03 08:50:06 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Nov 03 08:50:09 2013] [notice] Digest: generating secret for digest authentication ...
[Sun Nov 03 08:50:09 2013] [notice] Digest: done
[Sun Nov 03 08:50:10 2013] [notice] Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
最后设法解决它.
首先我看错了目录,我应该查看/ applications / xampp / xamppfiles /.

我所做的事情清单:

> / applications / xampp / xamppfiles下没有tmp文件夹,所以我创建了它(mkdir tmp).
>我搜索MysqL.sock文件,并在/applications/xampp/xamppfiles/var/MysqL/MysqL.sock下找到它.

由于MysqL服务器连接无法通过socket /tmp/MysqL.sock工作,我使用以下命令将我的/applications/xampp/xamppfiles/var/MysqL/MysqL.sock指向/tmp/MysqL.sock文件.

所以这个命令做了诀窍:

ln -s /applications/xampp/xamppfiles/var/MysqL/MysqL.sock /tmp/MysqL.sock

>现在我重新启动xampp服务并运行:MysqL -u root -p,我可以进入MysqL控制台.我也尝试从PHP脚本连接MysqL并运行正常.

拔头发一天半后我终于设法让它工作希望人们会觉得这很有帮助.

原文地址:https://www.jb51.cc/php/137527.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐