简体   繁体   English

Laravel 5.2工匠的“迁移”无效

[英]Laravel 5.2 artisan 'migrate' is not working

The title description pretty much says it all. 标题说明几乎说明了一切。 When I run php artisan migrate inside my project's folder (in my Macbook), it errors out with the following: 当我在项目的文件夹(在Macbook中)中运行php artisan migrate migration时,出现以下错误:

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

I have taken the time to browse around the error and try some fixes, but the only way I got it to work is if I actually ssh into my vagrant box (homestead) and run the migration from there, but I am trying to actually run it from my terminal window locally without ssh-ing into homestead. 我已经花时间浏览错误并尝试了一些修复程序,但是使它起作用的唯一方法是,如果我实际上是将ssh放入我的无家可归的盒子(宅基地)并从那里运行迁移,但是我试图实际运行它从本地终端窗口本地访问,而无需进入宅基地。

Do you know what can be causing this problem? 您知道什么可能导致此问题吗?

Thank you for all your help in advance! 谢谢您提前提供的所有帮助!

Cheers! 干杯!

UPDATE: 更新:

Before I thought it was due to MAMP being installed in my computer. 在我以为这是由于我的计算机中安装了MAMP之前。 But currently I am not using any servers or anything like that that can be messing with port 3306 since I have a fresh El Capitan install. 但是,由于我重新安装了El Capitan,因此目前我没有使用任何服务器或类似的端口3306。

Check out the answers here: PDOException SQLSTATE[HY000] [2002] No such file or directory 在此处查看答案: PDOException SQLSTATE [HY000] [2002]没有此类文件或目录

You'll need to change the hostname in your mysql config according to this: 您需要根据以下命令在mysql配置中更改主机名:

Laravel 4: Change "host" in the app/config/database.php file from "localhost" to "127.0.0.1" Laravel 4:将app / config / database.php文件中的“主机”从“本地主机”更改为“ 127.0.0.1”

Laravel 5: Change "DB_HOST" in the .env file from "localhost" to "127.0.0.1" Laravel 5:将.env文件中的“ DB_HOST”从“ localhost”更改为“ 127.0.0.1”

Laravel w/ Homestead: Use the directions above for the Laravel version you are using BUT change "localhost" to the IP address specified in Homestead.yaml. 带有Homestead的Laravel:使用以上说明,将您正在使用的Laravel版本更改为“ localhost”,更改为Homestead.yaml中指定的IP地址。 The default is "192.168.10.10" instead of "127.0.0.1" 默认值为“ 192.168.10.10”,而不是“ 127.0.0.1”

i also faced this problem. 我也面临这个问题。 i solved this problem. 我解决了这个问题。

Just edit your .env file. 只需编辑您的.env文件。 Change DB_HOST=localhost to DB_HOST=127.0.0.1 DB_HOST=localhost更改为DB_HOST=127.0.0.1

and the funny think is, the reverse is true in some cases. 有趣的是,在某些情况下情况恰恰相反。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM