mysql - Magento - 尽管在 local.xml 中设置了远程 IP,但仍尝试通过 unix 套接字进行连接

标签 mysql magento

 <default_setup>
                <connection>
                    <host><![CDATA[10.1.39.35]]></host>
                    <username><![CDATA[user]]></username>
                    <password><![CDATA[password]]></password>
                    <dbname><![CDATA[db_magento]]></dbname>
                    <active>1</active>
                </connection>
            </default_setup>

我的 local.xml 文件配置如上所示。 我收到此错误

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

Trace:
#0 /home/ecosmart/public_html/e-nrg.com/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /home/ecosmart/public_html/e-nrg.com/lib/Varien/Db/Adapter/Pdo/Mysql.php(251): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /home/ecosmart/public_html/e-nrg.com/lib/Zend/Db/Adapter/Abstract.php(448): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /home/ecosmart/public_html/e-nrg.com/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 /home/ecosmart/public_html/e-nrg.com/lib/Varien/Db/Adapter/Pdo/Mysql.php(333): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Resource/Type/Db/Pdo/Mysql.php(45): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 /home/ecosmart/public_html/e-nrg.com/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 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(297): Mage_Core_Model_Resource->getConnection('core_read')
#8 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(312): Mage_Core_Model_Mysql4_Abstract->_getConnection('read')
#9 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Mysql4/Cache.php(41): Mage_Core_Model_Mysql4_Abstract->_getReadAdapter()
#10 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Cache.php(424): Mage_Core_Model_Mysql4_Cache->getAllOptions()
#11 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Cache.php(459): Mage_Core_Model_Cache->_initOptions()
#12 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/App.php(1101): Mage_Core_Model_Cache->canUse('config')
#13 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Config.php(404): Mage_Core_Model_App->useCache('config')
#14 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/Config.php(286): Mage_Core_Model_Config->_canUseCacheForInit()
#15 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/App.php(359): Mage_Core_Model_Config->loadModulesCache()
#16 /home/ecosmart/public_html/e-nrg.com/app/code/core/Mage/Core/Model/App.php(295): Mage_Core_Model_App->_initModules()
#17 /home/ecosmart/public_html/e-nrg.com/app/Mage.php(596): Mage_Core_Model_App->run(Array)
#18 /home/ecosmart/public_html/e-nrg.com/index.php(83): Mage::run('', 'store')
#19 {main}

我一直在互联网上查找,但找不到与此有相同问题的人=每个人都说当他们在不同端口上运行本地 mysql 时会发生这种情况。我不是,我正在运行一个单独的服务器,其中的数据库通过内部网络联网。

有谁知道停止 magento 使用 MYSQL 套接字连接并强制其使用 TCP 协议(protocol)的解决方法吗?

谢谢

最佳答案

你清理缓存了吗? rm -rf var/cache

关于mysql - Magento - 尽管在 local.xml 中设置了远程 IP,但仍尝试通过 unix 套接字进行连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8129626/

相关文章:

php - MySQL 5.5 到 5.7 停止使用索引

php - 如何在 Magento 中更改订单起始编号

php - 如何根据第一个表匹配获取第二个和第三个表的数据

c# - MYSQL 插入...重复值再次插入增量

python - 保存后更新FK模型DateField

ruby-on-rails - rails - 在 magento api REST 上请求 token

magento - Magento结构 block ,内容 block 和phtml模板

php - sql更新不起作用不知道如何修复

mysql - 为什么 MyModel.offset(n).find(20) 在带有 MySQL 的 Rails 3 中这么慢?

php - 登录和结帐页面需要 SSL 的 Magento index.php [HTTP 404]