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.
I encountered the
[PDOException] SQLSTATE[HY000] [2002] No such file or directory
error for a different reason. I had just finished building a brand new LAMP stack on Ubuntu 12.04 with Apache 2.4.7, PHP v5.5.10 and MySQL 5.6.16. I moved my sites back over and fired them up. But, I couldn't load my Laravel 4.2.x based site because of the[PDOException]
above. So, I checkedphp -i | grep pdo
and noticed this line:But, in my /etc/my.cnf the sock file is actually in
/var/run/mysqld/mysqld.sock
.So, I opened up my php.ini and set the value for
pdo_mysql.default_socket
:Then, I restarted apache and checked
php -i | grep pdo
:That fixed it for me.
If you are using Laravel Homestead, make sure you're calling the commands on the server.
Then simply cd to the right directory and fire your command there.
If you are using Laravel Homestead, here is settings
(include Vagrant-Virtual Machine)
.bash-profile
database.php
Terminal
I had this problems when I was running my application using docker containers.
The solution was put the name of the MySQL service container I was using in
docker_compose.yml
on DB_HOST. In my case, it wasdb
:Hope it helps.
In my case, I was running php artisan migrate on my mac terminal, when I needed to ssh into vagrant and run it from there. Hope that helps someone the headache.
For anyone trying to create a fresh db connection not on laravel but bumped here seeking for answers to run PDO from the Terminal. This would be of help to you. And you can refactor it to work best for you.
hope it helps!