Error:PDOException SQLSTATE[HY000] [2020] No such file or directory in php?

0 votes

 I have successfully deployed my 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?

Thanxx!!

Apr 2 in PHP by kartik
• 26,540 points
122 views

1 answer to this question.

0 votes

Hello,

I checked php -i | grep pdo and noticed this line:

pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock

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:

pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock

Then, I restarted apache and checked php -i | grep pdo:

pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

That fixed it for me.

Hope this works fine!

Thank You!

answered Apr 2 by Niroj
• 57,260 points

Related Questions In PHP

0 votes
1 answer

Error:Enabling error display in PHP via htaccess only?

Hello, To turn the actual display of errors ...READ MORE

answered May 19 in PHP by Niroj
• 57,260 points
84 views
0 votes
1 answer

Invalid argument supplied for foreach() on line 25. Error in my php and mysql

Hello @viven , This should be a simple fix ...READ MORE

answered Aug 4 in PHP by Niroj
• 57,260 points
97 views
0 votes
1 answer
0 votes
1 answer

Error:Undefined index: barangay in C:\xampp\htdocs\TextBlast\homepage\insert.php on line 22

Hello @ Regina, First checks whether a variable is ...READ MORE

answered Aug 14 in PHP by Niroj
• 57,260 points
77 views
0 votes
1 answer

What is Laravel framework? Why one should use Laravel?

Laravel is a PHP web-framework; it utilized ...READ MORE

answered Mar 17 in Laravel by Niroj
• 57,260 points
164 views
0 votes
1 answer

How to download and install Lavavel framework?

Hey @kartik, First you must have xampp install ...READ MORE

answered Mar 17 in Laravel by Niroj
• 57,260 points
166 views
0 votes
1 answer

How can we get started with Laravel through Xampp?

Hii, First you need to start Apache and ...READ MORE

answered Mar 17 in Laravel by Niroj
• 57,260 points
70 views
0 votes
1 answer

What are the important directories used in a common Laravel application

Hey @Kartik. Directories used in a common Laravel ...READ MORE

answered Mar 17 in Laravel by Niroj
• 57,260 points
95 views
0 votes
1 answer

Error:Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23

Hello @kartik, This error message gets triggered when anything is ...READ MORE

answered 5 days ago in PHP by Niroj
• 57,260 points
17 views
0 votes
1 answer

ERROR: The file 'wp-config.php' already exists

Hello, Try to display the website first on ...READ MORE

answered May 8 in PHP by Niroj
• 57,260 points
496 views