-1

PC に 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ローカル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 に答える