Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Problems with mysql socket connection. SQLSTATE[HY000] [2002]
 
harkman
Member
 
Avatar
Total Posts:  60
Joined:  2008-01-06
Ravensburg, Germany
 

Hello.

Today i was trying to install the new release. I already managed to install the 0.6 release so I have some experience with the procedure.

My system is a virtual debian linux. uname -a is Linux 2.6.9-023stab044.16-enterprise #1 SMP Fri Nov 23 20:56:09 MSK 2007 i686 GNU/Linux
MySQL Client API is 5.0.27.

Configuring Magento database connection gives me following error for host=/var/run/mysqld/mysqld.sock:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
aparently the configuration setting is ignored.

my phpinfo tells me that i have set:
MYSQL_SOCKET=/tmp/mysql.sock
and
mysql.default_socket=/var/run/mysqld/mysqld.sock

AFAIK the MYSQL_SOCKET value is a compiletime setting of the PHP mysql API. Therefore i did not find any way to change this setting to the correct value.

What made me wonder is, that magento seems to prioritize MYSQL_SOCKET value over the php.ini setting mysql.default_socket.
Even setting the host setting in magento will be ignored.
Currently my workaround is to set the host value to 127.0.0.1 to force connection to use networking and not the filesocket.

I’m reporting this because Im unsure if this is a magento bug or sth else.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Magento does not use system settings for mysql connection, just standard Zend_Db connection config.
Maybe PDO_MYSQL driver prefers MYSQL_SOCKET setting over the supplied argument…

 
Magento Community Magento Community
Magento Community
Magento Community
 
kaspersko23
Jr. Member
 
Total Posts:  11
Joined:  2011-06-30
 

Hi,
I have the same problem, i don’t know zend configuration and how to configure socket path with zend in magento, i tried to edit php.ini, my.cnf ...reinstall mysql but problems occured, i work with ubuntu locally , also when i tried to start mysql

sudo service mysql start
it crashes. Thank you in advance.
[SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)

Trace:
#0 /var/www/magento/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /var/www/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(251): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /var/www/magento/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /var/www/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('
SET NAMES utf8', Array)
#4 /var/www/magento/lib/Varien/Db/Adapter/Pdo/Mysql.php(337): Zend_Db_Adapter_Pdo_Abstract->query('
SET NAMES utf8', Array)
#5 /var/www/magento/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(45): Varien_Db_Adapter_Pdo_Mysql->query('
SET NAMES utf8')
#6 /var/www/magento/app/code/core/Mage/Core/Model/Resource.php(93): Mage_Core_Model_Resource_Type_Db_Pdo_Mysql->getConnection(Object(Mage_Core_Model_Config_Element))
#7 /var/www/magento/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(297): Mage_Core_Model_Resource->getConnection('
core_read')
#8 /var/www/magento/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(312): Mage_Core_Model_Mysql4_Abstract->_getConnection('
read')
#9 /var/www/magento/app/code/core/Mage/Core/Model/Mysql4/Cache.php(41): Mage_Core_Model_Mysql4_Abstract->_getReadAdapter()
#10 /var/www/magento/app/code/core/Mage/Core/Model/Cache.php(434): Mage_Core_Model_Mysql4_Cache->getAllOptions()
#11 /var/www/magento/app/code/core/Mage/Core/Model/Cache.php(469): Mage_Core_Model_Cache->_initOptions()
#12 /var/www/magento/app/code/core/Mage/Core/Model/App.php(1144): Mage_Core_Model_Cache->canUse('
config')
#13 /var/www/magento/app/code/core/Mage/Core/Model/Config.php(412): Mage_Core_Model_App->useCache('
config')
#14 /var/www/magento/app/code/core/Mage/Core/Model/Config.php(294): Mage_Core_Model_Config->_canUseCacheForInit()
#15 /var/www/magento/app/code/core/Mage/Core/Model/App.php(395): Mage_Core_Model_Config->loadModulesCache()
#16 /var/www/magento/app/code/core/Mage/Core/Model/App.php(329): Mage_Core_Model_App->_initModules()
#17 /var/www/magento/app/Mage.php(627): Mage_Core_Model_App->run(Array)
#18 /var/www/magento/index.php(80): Mage::run('', '
store')
#19 {main}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top