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:
[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.
Do you know what can be causing this problem?
Thank you for all your help in advance!
Cheers!
Before I thought it was due to MAMP being installed in my computer. 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.
Check out the answers here: PDOException SQLSTATE[HY000] [2002] No such file or directory
You'll need to change the hostname in your mysql config according to this:
Laravel 4: Change "host" in the app/config/database.php file from "localhost" to "127.0.0.1"
Laravel 5: Change "DB_HOST" in the .env file from "localhost" to "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. The default is "192.168.10.10" instead of "127.0.0.1"
i also faced this problem. i solved this problem.
Just edit your .env file. Change DB_HOST=localhost
to DB_HOST=127.0.0.1
and the funny think is, the reverse is true in some cases.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.