错误日志中的“ SQLSTATE [HY000] [2002]没有这样的文件或目录”是什么意思?


8

该页面刚刚开始出现:

处理您的请求时出错

a:4:{i:0;s:48:"SQLSTATE[HY000] [2002] No such file or directory";i:1;s:2075:"#0 /home/dtacolle/public_html/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /home/dtacolle/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(313): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 /home/dtacolle/public_html/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 /home/dtacolle/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 /home/dtacolle/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#7 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write')
#8 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract->_getConnection('write')
#9 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(335): Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter()
#10 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Resource/Config.php(55): Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter()
#11 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Config.php(354): Mage_Core_Model_Resource_Config->loadToXml(Object(Mage_Core_Model_Config))
#12 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/Config.php(260): Mage_Core_Model_Config->loadDb()
#13 /home/dtacolle/public_html/app/code/core/Mage/Core/Model/App.php(270): Mage_Core_Model_Config->init(Array)
#14 /home/dtacolle/public_html/app/Mage.php(640): Mage_Core_Model_App->init('dtacollectibles...', 'website', Array)
#15 /home/dtacolle/public_html/get.php(113): Mage::init('dtacollectibles...', 'website')
#16 {main}";s:3:"url";s:91:"/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/c/o/con-dc-0007_2.jpg";s:11:"script_name";s:8:"/get.php";}

Answers:


12

看看PDOException SQLSTATE [HY000] [2002]没有这样的文件或目录

检查/app/etc/local.xml中的“主机”设置

尝试将其从“ localhost”更改为“ 127.0.0.1”


重新启动服务器,现在站点已备份。谢谢
Hector

有人知道magento 2是什么吗?没有看到/app/etc/local.xml
罗伯特·辛克莱

2
@RobertSinclair ...参见app / etc / env.php
Renon Stewart,

我在本地用... sudo服务mysql start解决了这个问题
Silas Palmer

0

基于上面Renon的答案,但针对Magento 2(因为没有/app/etc/local.xml)

您可以将localhost更改为127.0.0.1

app / etc / env.php

顺便说一句,如果您在执行“静态内容部署”之类的命令时遇到此错误,则另一个解决方法是仅使用另一个PHP版本执行您的命令(这意味着:如果启动并运行了Magento,但此命令失败,则可能是命令行使用的PHP版本与服务器使用的PHP版本之间的断开连接)

因此,就我而言,只需执行以下命令即可:

/Applications/MAMP/bin/php/php7.1.8/bin/php bin / magento设置:静态内容:部署-f **

^用您的PHP可执行文件替换/Applications/MAMP/bin/php/php7.1.8/bin/php

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.