It's printing an error message about some files, but I couldn't find the files on my server in the directory of /run.

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

# 0 /var/www/html/lib/Zend/Db/Adapter/Pdo/Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect()
# 1 /var/www/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(396): Zend_Db_Adapter_Pdo_Mysql->_connect()
# 2 /var/www/html/lib/Zend/Db/Adapter/Abstract.php(460): Varien_Db_Adapter_Pdo_Mysql->_connect()
# 3 /var/www/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
# 4 /var/www/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
# 5 /var/www/html/app/code/core/Mage/Core/Model/Resource.php(179): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
# 6 /var/www/html/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
# 7 /var/www/html/app/code/core/Mage/Core/Model/Resource/Setup.php(141): Mage_Core_Model_Resource->getConnection('core_setup')
# 8 /var/www/html/app/code/core/Mage/Core/Model/Resource/Setup.php(234): Mage_Core_Model_Resource_Setup->__construct('core_setup')
# 9 /var/www/html/app/code/core/Mage/Core/Model/App.php(428): Mage_Core_Model_Resource_Setup::applyAllUpdates()
# 10 /var/www/html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Model_App->_initModules()
# 11 /var/www/html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
# 12 /var/www/html/index.php(83): Mage::run('', 'store')
# 13 {main}
  • Finally fixed it.
    – YKB
    Aug 24, 2018 at 6:12
  • Hi I have the same problem as you but I can't figure out how to fix it by following your steps. I cannot access any magento panels, but only phpmyadmin and the files on the server Dec 15, 2021 at 10:05

1 Answer 1


Finally resolved below are the steps to do:

Step #1 First can create the mysqld/ directory in /var/run/: sudo mkdir -p /var/run/mysqld/

Step #2 Then create a mysqld.pid file: sudo touch /var/run/mysqld/mysqld.pid

Step #3 Create a mysqld.sock file: sudo touch /var/run/mysqld/mysqld.sock

Step #4 Then you have to change the ownership of the directory and files to mysql:mysql like the below: sudo chown mysql:mysql -R /var/run/mysqld

Step #5 And finally restart the MySQL: sudo service mysql restart

Step #6 That’s it you did all done well, MySQL will be able to create the mysqld.pid and mysqld.sock files in the root directory. Great work & Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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