Further explanation of the above.
Magento is asking PHP to go find MySQL’s socket file to use it for communication with the database.
It will be defined in the my.cnf file and the problem may be that the Apache DSO version of PHP cannot find it.
Search your php.ini file specific for the PHP DSO module:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
Note the blank line, php cannot find the seat of its pants with both hands and a flashlight. Go find my.cnf
Change the pdo_mysql.default_socket line in php.ini as follows:
And then restart Apache so it reloads the php.ini file. It should now have the flashlight and motor skills necessary…
Another cause may be that the directory for the mysql.sock may be missing or have wrong permissions set. Typically, mysqld runs as user mysqld. After looking at your my.cnf file in the [mysqld] section at the socket= entry, check to make sure the path to the file location exists.
Go to /var and look for a directory named mysql owned by mysql.root, create it if it’s missing. Mysql will then proceed to create mysql.sock with the proper permissions