加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 尝试了所有仍然得到ERROR 2002(HY000)的东西:无法通过so

发布时间:2020-12-13 13:28:37 所属栏目:PHP教程 来源:网络整理
导读:每次我运行xampp并尝试运行$ mysql -u root -p时,它抛出的错误是: ERROR 2002(HY000):无法通过套接字’/tmp/mysql.sock’连接到本地 MySQL服务器(2) 我在mac OS-10.9中使用xampp 1.7.3版.启动Apache和mysql不是问题,我已经确认apache已经开始进入活动监视
每次我运行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并运行正常.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读