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.
In may case, I'd simply used
instead of
for my forge larval setup using homestead. I'm assuming this meant the site was getting served, but the MySQL server wasn't ever booted. When I used the latter command to launch my vagrant box, the error went away.
All these answers seem like heavy lifting...
I just created a
.env
file; edited mybootstrap/app.php
file, and uncommented the following line...Dotenv::load(__DIR__.'/../');
Hope this helps someone
This is because PDO treats "localhost" host specially:
(from http://php.net/manual/en/ref.pdo-mysql.connection.php)
Changing localhost to 127.0.0.1 will "force" the use of TCP.
Note: mysqli_connect is working fine with localhost.
The error message indicates that a MySQL connection via socket is tried (which is not supported).
In the context of Laravel (artisan), you probably want to use a different / the correct environment. Eg:
php artisan migrate --env=production
(or whatever environment). See here.I got the same problem and I'm running Mac OS X 10.10 Yosemite. I have enabled the Apache Server and PHP that already comes with the OS. Then I just configured the mCrypt library to get started. After that when I was working with models and DB I got the error:
The reason I found is just because PHP and MySQL can't get connected themselves. To get this problem fixed, I follow the next steps:
Open a terminal and connect to the mysql with:
It will ask you for the related password. Then once you get the mysql promt type the next command:
You will get something like this:
Keep the value of the last row:
In your
laravel
project folder, look for the database.php file there is where you configure the DB connection parameters. In the mysql section add the next line at the end:You must have something like this:
Now just save changes, and reload the page and it must work!
Mamp user enable option Allow network access to MYSQL