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
or php artisan db:seed
) I get an error message:
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
At some point the migration must have worked, because my tables are there - but this doesn't explain why it isn't working for me now.
This happened to me because MySQL wasn't running. MySQL was failing to start because I had a missing
/usr/local/etc/my.cnf.d/
directory.This was being required by my
/usr/local/etc/my.cnf
config file as a glob include (include /usr/local/etc/my.cnf.d/*.cnf
).Running
mkdir /usr/local/etc/my.cnf.d
, and then starting MySQL, fixed the issue.I had the same problem using Docker and MySQL service name
db
in docker_compose.yml file:I added the following in the
.env
file:you should also assure that your host is discoverable from the php app.
It was because PHP didn't figure out which host to use to connect.
Step 1
Find the path to your unix_socket, to do that just run
netstat -ln | grep mysql
You should get something like this
Step 2
Take that and add it in your unix_socket param
Hope it helps !!
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
As of Laravel 5 the database username and password goes in the .env file that exists in the project directory, e.g.
As you can see these environment variables are overriding the 'forge' strings here so changing them has no effect:
More information is here https://mattstauffer.co/blog/laravel-5.0-environment-detection-and-environment-variables
In my case I had to remove the bootstrap/cache folder and try it again.
My cenario was after a server migration.