-1

我已经在我的电脑上安装了 memcached 1.4,以下 php 代码运行良好:

<?php
     $memcache = new Memcache;
     $memcache->connect("localhost",11211); # You might need to set  "localhost" to "127.0.0.1"

    echo "Server's version: " .  $memcache->getVersion() . "<br />\n";

    $tmp_object =  new stdClass;
    $tmp_object->str_attr = "test";
     $tmp_object->int_attr = 123;

     $memcache->set("key",$tmp_object,false,10);
    echo "Store data  in the cache (data will expire in 10 seconds)<br />\n";

     echo "Data from the cache:<br />\n";
     var_dump($memcache->get("key"));
?>

现在我想将 memcache 添加到 magento。我改变了 ma local xml 从

<?xml version="1.0"?>
<!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject 
    to the Academic Free License (AFL 3.0) * that is bundled with this package 
    in the file LICENSE_AFL.txt. * It is also available through the world-wide-web 
    at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not 
    receive a copy of the license and are unable to * obtain it through the world-wide-web, 
    please send an email * to license@magentocommerce.com so we can send you 
    a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if 
    you wish to upgrade Magento to newer * versions in the future. If you wish 
    to customize Magento for your * needs please refer to http://www.magentocommerce.com 
    for more information. * * @category Mage * @package Mage_Core * @copyright 
    Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License 
    (AFL 3.0) */ -->
<config>
    <global>

        <install>
            <date><![CDATA[Tue, 09 Oct 2012 15:36:30 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[]]>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]>
                </table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[]]>
                    </password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]>
                    </pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[db]]></session_save>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

<?xml version="1.0"?>
<!-- /** * Magento * * NOTICE OF LICENSE * * This source file is subject 
    to the Academic Free License (AFL 3.0) * that is bundled with this package 
    in the file LICENSE_AFL.txt. * It is also available through the world-wide-web 
    at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not 
    receive a copy of the license and are unable to * obtain it through the world-wide-web, 
    please send an email * to license@magentocommerce.com so we can send you 
    a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if 
    you wish to upgrade Magento to newer * versions in the future. If you wish 
    to customize Magento for your * needs please refer to http://www.magentocommerce.com 
    for more information. * * @category Mage * @package Mage_Core * @copyright 
    Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 
    * @license http://opensource.org/licenses/afl-3.0.php Academic Free License 
    (AFL 3.0) */ -->
<config>
    <global>

        <install>
            <date><![CDATA[Tue, 09 Oct 2012 15:36:30 +0000]]></date>
        </install>
        <crypt>
            <key><![CDATA[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]]></key>
        </crypt>
        <disable_local_modules>false</disable_local_modules>
        <resources>
            <db>
                <table_prefix><![CDATA[]]>
                </table_prefix>
            </db>
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username><![CDATA[root]]></username>
                    <password><![CDATA[]]>
                    </password>
                    <dbname><![CDATA[magento]]></dbname>
                    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                    <model><![CDATA[mysql4]]></model>
                    <type><![CDATA[pdo_mysql]]></type>
                    <pdoType><![CDATA[]]>
                    </pdoType>
                    <active>1</active>
                </connection>
            </default_setup>
        </resources>
        <session_save><![CDATA[db]]></session_save>
        <cache>
            <backend>memcached</backend><!-- apc / memcached / empty=file -->
            <memcached><!-- memcached cache backend related config -->
                <servers><!-- any number of server nodes can be included -->
                    <server>
                        <host><![CDATA[127.0.0.1]]></host>
                        <port><![CDATA[11211]]></port>
                        <persistent><![CDATA[1]]></persistent>
                    </server>
                </servers>
                <compression><![CDATA[0]]></compression>
                <cache_dir><![CDATA[]]>
                </cache_dir>
                <hashed_directory_level><![CDATA[]]>
                </hashed_directory_level>
                <hashed_directory_umask><![CDATA[]]>
                </hashed_directory_umask>
                <file_name_prefix><![CDATA[]]>
                </file_name_prefix>
            </memcached>
        </cache>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <frontName><![CDATA[admin]]></frontName>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

但现在我得到了错误

a:5:{i:0;s:86:"SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)";i:1;s:1653:"#0 \lib\Zend\Db\Adapter\Pdo\Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()

当我删除标签时,商店再次运行良好。怎么了?

4

1 回答 1

1

您有数据库连接问题。你有奇怪的local.xml格式你确定你有

<password><![CDATA[]]>
                    </password>

因为默认情况下它应该是

<password><![CDATA[]]></password>

Xml 解析器将带换行符和不带换行符的节点读取为 2 个不同的字符串。您可以通过添加来检查它

var_dump($this->_config['password']);

到 Zend_Db_Adapter_Pdo_Abstract::_connect()

于 2012-10-10T21:28:23.150 回答