fbpx

No Such File or Directory Error When Running php artisan migrate Locally

First, make sure that you are allowing network access to MySQL in MAMP 

Then, try adding the following key-value pair to the MySQL array in config/database.php.

'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',

Your MySQL array should now look like this:

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8mb4',
            'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

You should now be able to run php artisan migrate with no problems!

Leave a Reply

Your email address will not be published. Required fields are marked *