SQLSTATE [HY000] [2002]没有这样的文件或目录 [英] SQLSTATE[HY000] [2002] No such file or directory

查看:296
本文介绍了SQLSTATE [HY000] [2002]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OS X上运行laravel项目.我使用自制软件安装了MySql.我尝试四处搜寻,以了解为什么出现此错误的原因:

I am trying to run a laravel project on OS X. I installed MySql with homebrew. I tried googling around for why I'm getting this error:

SQLSTATE[HY000] [2002] No such file or directory

当我尝试做

php artisan migrate

我看到的大多数答案都说php和MySql无法相互通信.自从我认为我遵循先前的帖子以来,我一直在尝试找出出错的地方,但仍然无法正常工作.我创建了一个页面来完成此任务:

And most of the answers I see say php and MySql cannot communicate to each other. I've been trying to see where I went wrong since I think I followed previous posts about it, and it still doesn't work. I created a page that just does this:

<?php
    phpinfo();
?>

我看到了以下几种类型的东西: 在配置"区域中,我看到:

And I see these types of things: In the Configure area, I see:

'--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-zend-signals' '--enable-dtrace'

已加载的配置文件:

/usr/local/etc/php/5.4/php.ini

如果我ls /tmp,我确实会看到mysql.sock.

If I ls /tmp, I do see mysql.sock.

在该php.ini文件中,我设置了以下几行: pdo_mysql.default_socket =/tmp/mysql.sock mysql.default_socket =/tmp/mysql.sock mysqli.default_socket =/tmp/mysql.sock

In that php.ini file, I set these lines: pdo_mysql.default_socket=/tmp/mysql.sock mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock

然后在/usr/local/Cellar/mysql/5.6.16/my.cnf中,添加以下行:

And then in /usr/local/Cellar/mysql/5.6.16/my.cnf, I added the following line:

socket = /tmp/mysql.sock

我DID重新启动apache,以及检查mysql是否正在运行.除了php和mysql连接外,我没有看到任何其他建议.我认为系统上有两个版本的php,因为当我安装mcrypt或其他我不记得的东西时,它安装了另一个php版本.但是当我查看phpinfo的输出时,我正在编辑适当的php.ini文件.我不知道是否还有我想念的东西.有什么想法吗?谢谢

I DID restart apache, as well as check mysql is running. I haven't seen any other advice besides the php and mysql connection. I think there are two versions of php on my system because when I installed mcrypt or something else I can't remember, it installed another php version. But when I do look at the output of phpinfo, I'm editing the appropriate php.ini file. I didn't know if there is another piece I am missing. Any thoughts? Thanks

推荐答案

搜索后,我发现了该帖子:

After searching, I found this post:

在Mac php artisan迁移工具上设置Laravel:没有此类文件或目录

我添加了

'unix_socket' => '/tmp/mysql.sock’,

到mysql数组中的我的database.php,它起作用了.不确定为什么会这样,但是确实可以.

to my database.php in the mysql array, it worked. Not sure exactly why that works, but it does.

这篇关于SQLSTATE [HY000] [2002]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆