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.
It worked after I change from
DB_HOST=localhost
toDB_HOST=127.0.0.1
at .env fileI 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:
mysql -u root -p
It will ask you for the related password. Then once you get the mysql promt type the next command:
mysql> show variables like '%sock%'
You will get something like this:
+-----------------------------------------+-----------------+ | Variable_name | Value | +-----------------------------------------+-----------------+ | performance_schema_max_socket_classes | 10 | | performance_schema_max_socket_instances | 322 | | socket | /tmp/mysql.sock | +-----------------------------------------+-----------------+
Keep the value of the last row:
/tmp/mysql.sock
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:
'unix_socket' => '/tmp/mysql.sock'
You must have something like this:
'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'SchoolBoard', 'username' => 'root', 'password' => 'venturaa', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'unix_socket' => '/tmp/mysql.sock', ),
Now just save changes, and reload the page and it must work! I hope it could be useful!
When using a VirtualMachine make sure you ssh into that machine and navigate to your App folder and call the php artisan migrate command from there.
In my case i had no problem at all, just forgot to start the mysql service...
sudo service mysqld start
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 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.