Toby
Toby

Reputation: 8792

Laravel setup of migrations using Artisan is failing

I am trying to set up migrations for the first time and when I run

php artisan migrate:install

from within the root folder of my project I get the following SQLSTATE error:

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

I have tested running mysql to make sure it is working and referenced and I have ran php artisan help:commands to make sure artisan is working (it is).

The website itself is functioning and reading from the database fine.

Upvotes: 9

Views: 7298

Answers (2)

Edwin M
Edwin M

Reputation: 361

Also, try and change 'host' => 'localhost', to 'host'=> '127.0.0.1', because unix does not recognise 'localhost'

Upvotes: 8

J.T. Grimes
J.T. Grimes

Reputation: 4272

This may be an issue with the sockets if you're using MAMP or XAMPP.

From http://forums.laravel.io/viewtopic.php?id=980...

'connections' => array(
    'mysql' => array(
        'driver'   => 'mysql',
        'host'     => 'localhost',
        'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
        'database' => 'database',
        'username' => 'user',
        'password' => 'pass',
        'charset'  => 'utf8',
        'prefix'   => '',
    ),

),

You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location.

Upvotes: 27

Related Questions