Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in lib/Zend/Db/Adapter/Pdo/Abstract.php:129
I get the following error on my local machine. (Mac OSX running Apache/MySQL natively) I can run Magento from the frontend, but I can't reindex at the command.
-
1Just a comment, this part of Alan's fix worked You might also have some luck changing the server to 127.0.0.1 from localhost. (When the system sees an IP address, it knows not to connect via the socket file, but instead to connect via TCP)brentwpeterson– brentwpeterson2014年05月15日 21:41:34 +00:00Commented May 15, 2014 at 21:41
-
This comment may be help you magento.stackexchange.com/a/331463/93583Aryashree Pritikrishna– Aryashree Pritikrishna2021年02月20日 16:30:45 +00:00Commented Feb 20, 2021 at 16:30
3 Answers 3
Just a guess, but it sounds like
Your command line php executable uses a different
php.inifile than the web serverThe
php.inifile your command line version uses has a different, and invalid, value set for the mysql.default_socket ini setting
When you specify a MySQL server host as localhost, you're telling the system to use this socket file to connect to the database server. Check the value when using your local web-server, and make sure that same value is set for the command line program's ini file.
You might also have some luck changing the server to 127.0.0.1 from localhost. (When the system sees an IP address, it knows not to connect via the socket file, but instead to connect via TCP)
-
The change to
127.0.0.1fixed this issue in MAMP where re-indexing would fail from the command line.Brendan Falkowski– Brendan Falkowski2017年01月18日 00:35:10 +00:00Commented Jan 18, 2017 at 0:35
Here are some solutions to change the socket on a server:
http://pravams.com/2011/05/26/magento-pdo-exception/
And if you get the problem with MAMP/XAMPP, open a terminal to create symbolic link (that was my solution, tested on MAC OS X) :
MAMP:
sudo mkdir /var/mysql
cd /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock
XAMPP:
sudo mkdir /var/mysql
cd /var/mysql
sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
In my case the error was in settings of Mamp. Run Apache/MySQL server as www instead of as user. Once I changed that I was able to run shell scripts in shell/ directory without any errors