2

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.

  • 1
    Just 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 May 15 '14 at 21:41
10

Just a guess, but it sounds like

  1. Your command line php executable uses a different php.ini file than the web server

  2. The php.ini file 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.1 fixed this issue in MAMP where re-indexing would fail from the command line. – Brendan Falkowski Jan 18 '17 at 0:35
1

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

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.