"SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
**I know this question has been asked multiple times, using magento zend framework. Mediatemple hosting **
** a:4:{i:0;s:107:"SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)**

Stacktrace

    a:4:{i:0;s:107:"SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)";i:1;s:3001:"#0 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
    #1 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(251): Zend_Db_Adapter_Pdo_Mysql->_connect()
    #2 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
    #3 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
    #4 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
    #5 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(45): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
    #6 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/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 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(297): Mage_Core_Model_Resource->getConnection('core_read')
    #8 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(312): Mage_Core_Model_Mysql4_Abstract->_getConnection('read')
    #9 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Cache.php(41): Mage_Core_Model_Mysql4_Abstract->_getReadAdapter()
    #10 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Cache.php(434): Mage_Core_Model_Mysql4_Cache->getAllOptions()
    #11 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Cache.php(469): Mage_Core_Model_Cache->_initOptions()
    #12 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(1138): Mage_Core_Model_Cache->canUse('config')
    #13 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Config.php(412): Mage_Core_Model_App->useCache('config')
    #14 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Config.php(294): Mage_Core_Model_Config->_canUseCacheForInit()
    #15 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(395): Mage_Core_Model_Config->loadModulesCache()
    #16 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(329): Mage_Core_Model_App->_initModules()
    #17 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/Mage.php(627): Mage_Core_Model_App->run(Array)
    #18 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/index.php(80): Mage::run('', 'store')
    #19 {main}";s:3:"url";s:10:"/index.php";s:11:"script_name";s:10:"/index.php";}


I have tried everything. PDO works as a proof that the code below works fine

    <?php
    try {
        $dbh = new PDO('mysql:host=serverm;dbname=xxx', 'xxxx', 'xxxxx');
        echo 'Connected to database';
        }
    catch(PDOException $e)
        {
        echo $e->getMessage();
        }
    ?>


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

**I know this question has been asked multiple times, using magento zend framework. Mediatemple hosting **
** a:4:{i:0;s:107:"SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)**

Stacktrace

    a:4:{i:0;s:107:"SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)";i:1;s:3001:"#0 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
    #1 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(251): Zend_Db_Adapter_Pdo_Mysql->_connect()
    #2 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
    #3 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
    #4 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
    #5 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(45): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
    #6 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/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 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(297): Mage_Core_Model_Resource->getConnection('core_read')
    #8 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(312): Mage_Core_Model_Mysql4_Abstract->_getConnection('read')
    #9 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Mysql4/Cache.php(41): Mage_Core_Model_Mysql4_Abstract->_getReadAdapter()
    #10 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Cache.php(434): Mage_Core_Model_Mysql4_Cache->getAllOptions()
    #11 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Cache.php(469): Mage_Core_Model_Cache->_initOptions()
    #12 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(1138): Mage_Core_Model_Cache->canUse('config')
    #13 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Config.php(412): Mage_Core_Model_App->useCache('config')
    #14 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/Config.php(294): Mage_Core_Model_Config->_canUseCacheForInit()
    #15 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(395): Mage_Core_Model_Config->loadModulesCache()
    #16 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/code/core/Mage/Core/Model/App.php(329): Mage_Core_Model_App->_initModules()
    #17 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/app/Mage.php(627): Mage_Core_Model_App->run(Array)
    #18 /nfs/c09/h03/mnt/133843/domains/demo.tickettotimbuktu.com/html/index.php(80): Mage::run('', 'store')
    #19 {main}";s:3:"url";s:10:"/index.php";s:11:"script_name";s:10:"/index.php";}


I have tried everything. PDO works as a proof that the code below works fine

    <?php
    try {
        $dbh = new PDO('mysql:host=serverm;dbname=xxx', 'xxxx', 'xxxxx');
        echo 'Connected to database';
        }
    catch(PDOException $e)
        {
        echo $e->getMessage();
        }
    ?>

