SQLSTATE[HY000] [2002] No such file or directory
Details
During or after installation, a message similar to the following displays:
1
2
Exception' with message 'PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] No such file or directory
Solution
This is commonly caused by a different instance of PHP being used by the PHP command line compared to the web server. In particular, mysql.sock
might be misconfigured if this is the case.
To determine whether or not you’re using one instance of PHP:
- Log in to your Magento server.
-
Enter the following command:
1
php -i | grep 'php.ini'
This determines the settings used by the PHP command-line interface (CLI). Note where
php.ini
is located. - If you haven’t already done so, set up a phpinfo.php on your web server.
-
Compare the value of Loaded Configuration File from
phpinfo.php
with the one fromphp -i
.phpinfo.php
shows thephp.ini
file used by your web server. If it’s different from what’s in PHP’sphp.ini
, you must make all PHP settings consistent for both the PHP CLI and the web server.For additional details, consult the documentation provided with your web server.