ros*_*snk 8 php mysql sockets macos
每次我运行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 RESULT WAS:mysqladmin:在'localhost'连接到服务器失败错误:'无法连接到本地MySQL服务器通过socket'/tmp/mysql.sock'(2)'检查mysqld是否正在运行,并且socket:'/ 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
Run Code Online (Sandbox Code Playgroud)
ros*_*snk 12
最后设法解决它.首先我看错了目录,我应该调查一下/applications/xampp/xamppfiles/.
我所做的事情清单:
/ applications/xampp/xamppfiles下没有tmp文件夹,所以我创建了它(mkdir tmp).
我搜索了mysql.sock文件,发现它/applications/xampp/xamppfiles/var/mysql/mysql.sock.
由于mysql服务器连接无法通过套接字工作/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
Run Code Online (Sandbox Code Playgroud)
mysql -u root -p,我可以进入mysql控制台.我也尝试从php脚本连接mysql并运行正常.拔头发一天半后我终于设法让它工作希望人们会觉得这很有帮助.
不确定如何获取 Mac 上正在运行的程序的列表,但您应该尝试验证 mysqld 是否确实正在运行。(在 Linux 上,“top -bn1 | grep mysql”如果正在运行,通常会显示一行信息,如果没有运行,则什么也不显示。)
您还可以尝试停止 mysqld 并查看 /tmp/mysql.sock 是否消失。如果没有出现,请尝试删除它并重新启动 mysql,看看它是否再次出现。(它应该)
您是否有任何可能显示正在发生的情况的日志文件?
| 归档时间: |
|
| 查看次数: |
8316 次 |
| 最近记录: |