Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 779
Toby Avatar asked Jan 08 '13 16:01

Toby


2 Answers

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.

like image 105
J.T. Grimes Avatar answered Oct 13 '22 11:10

J.T. Grimes


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

like image 21
Edwin M Avatar answered Oct 13 '22 11:10

Edwin M