I believe that I\'ve successfully deployed my (very basic) site to fortrabbit, but as soon as I connect to SSH to run some commands (such as php artisan migrate
Find the path to your unix_socket, to do that just run netstat -ln | grep mysql
You should get something like this
unix 2 [ ACC ] STREAM LISTENING 17397 /var/run/mysqld/mysqld.sock
Take that and add it in your unix_socket param
'mysql' => array(
'driver' => 'mysql',
'host' => '67.25.71.187',
'database' => 'dbname',
'username' => 'username',
'password' => '***',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'unix_socket' => '/var/run/mysqld/mysqld.sock' <-----
),
),
Hope it helps !!
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"
I had the exact same problem. None of the above solutions worked for me. I solved the problem by changing the "host" in the /app/config/database.php file from "localhost" to "127.0.0.1".
Not sure why "localhost" doesn't work by default but I found this answer in a similar question solved in a symfony2 post. https://stackoverflow.com/a/9251924/1231563
Update: Some people have asked as to why this fix works so I have done a little bit of research into the topic. It seems as though they use different connection types as explained in this post https://stackoverflow.com/a/9715164/1231563
The issue that arose here is that "localhost" uses a UNIX socket and can not find the database in the standard directory. However "127.0.0.1" uses TCP (Transmission Control Protocol), which essentially means it runs through the "local internet" on your computer being much more reliable than the UNIX socket in this case.
Add mysql.sock path in database.php file like below example
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
Eample
'mysql' => [
'driver' => 'mysql',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '8889'),
If anyone are still looking for the answer, just check your .env file. For some reason laravel create a .env.example file, so all this answers didn't work for me. I fixed my issue renamming .env.example to .env
The answer from @stuyam solved the "No such file or directory" issue for me
Short answer: Change "host" in the /app/config/database.php file from "localhost" to "127.0.0.1"
But then I had a "Connection refused" error. If anyone had the same issue, my solution for this was to update the app/config/local/database.php file so the port is 8889:
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '8889',
'database' => 'databaseName',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
Mamp user enable option Allow network access to MYSQL