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
@H_403_25@ 最后设法解决它.
首先我看错了目录,我应该查看/ 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并运行正常.

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

相关文章

Hessian开源的远程通讯,采用二进制 RPC的协议,基于 HTTP 传输。可以实现PHP调用Java,Python,C#等多语...
初识Mongodb的一些总结,在Mac Os X下真实搭建mongodb环境,以及分享个Mongodb管理工具,学习期间一些总结...
边看边操作,这样才能记得牢,实践是检验真理的唯一标准.光看不练假把式,光练不看傻把式,边看边练真把式....
在php中,结果输出一共有两种方式:echo和print,下面将对两种方式做一个比较。 echo与print的区别: (...
在安装好wampServer后,一直没有使用phpMyAdmin,今天用了一下,phpMyAdmin显示错误:The mbstring exte...
变量是用于存储数据的容器,与代数相似,可以给变量赋予某个确定的值(例如:$x=3)或者是赋予其它的变...