更改 Magento 配置以使用套接字
我的数据库配置已更改,因此 Magento 无法再连接。连接之前工作,但现在似乎需要一个套接字配置值...
我的 local.xml 配置中的相关部分如下所示:
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[dbname]]></dbname>
<active>1</active>
<model>mysql5</model>
<initStatements>SET NAMES utf8</initStatements>
<type>pdo_mysql</type>
</connection>
由于 Magento 使用 PDO,这里是我能够连接的测试脚本代码:
$user = 'username';
$pass = 'password';
// PDO Connection
try {
/* DB CONNECTION */
$pdoMysql = new PDO('mysql:host=localhost;unix_socket=/tmp/mysql5.sock;dbname=dbname', $user, $pass);
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
所以基本上我需要添加“unix_socket=/tmp/mysql5.sock;”某处...
谢谢
my database config has changed so Magento is not able to connect anymore. The connection before worked but now it seems to need a socket config value...
The relevant part in my local.xml config looks like this:
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[username]]></username>
<password><![CDATA[password]]></password>
<dbname><![CDATA[dbname]]></dbname>
<active>1</active>
<model>mysql5</model>
<initStatements>SET NAMES utf8</initStatements>
<type>pdo_mysql</type>
</connection>
Since Magento uses PDO here's my testscript code that is able to connect:
$user = 'username';
$pass = 'password';
// PDO Connection
try {
/* DB CONNECTION */
$pdoMysql = new PDO('mysql:host=localhost;unix_socket=/tmp/mysql5.sock;dbname=dbname', $user, $pass);
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
So basically I need to add "unix_socket=/tmp/mysql5.sock;" somewhere...
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将套接字路径放在
位中you simply place the socket path in the
<host/>
bit按照说明更改主机,然后删除
app/etc/use_cache.ser
并重试:)Change the host as stated, then delete
app/etc/use_cache.ser
and retry :)