While setting up a new project in MAMP for my day job I ran into an odd problem trying to run artisan migrations.

Running this command:

php artisan migrate:refresh --env=local

Threw this error:

{"error":{"type":"PDOException","message":"SQLSTATE[HY000] [2002] No such file or directory","file":"\/Users\/halo\/PhpstormProjects\/project\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Connectors\/Connector.php","line":47}}%

A quick google search came up with this which pointed to:

Short answer: Change "host" in the /app/config/database.php file from "localhost" to ""

Changing that fixed my issue, but what was the actual cause of the issue?

I installed PHP locally using Homebrew, and MAMP is using it’s own versions of PHP and since I was running artisan against my Homebrew version of PHP I needed to point


to the MySQL socket from MAMP.





resolved my issue.

Hopefully this helps someone else.