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.

asked Nov 13, 2013 at 22:16
2
  • 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) Commented May 15, 2014 at 21:41
  • This comment may be help you magento.stackexchange.com/a/331463/93583 Commented Feb 20, 2021 at 16:30

3 Answers 3

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)

answered Nov 14, 2013 at 3:19
1
  • The change to 127.0.0.1 fixed this issue in MAMP where re-indexing would fail from the command line. Commented Jan 18, 2017 at 0:35
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
answered Sep 11, 2014 at 8:40
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

answered Apr 6, 2015 at 17:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.