Pergunta

So I had a website up at http://www.avantalarm.com/ and after many issues trying to add modules, I decided I'd export it to a local WAMP server to work on my development so I didn't break the site while trying to figure things out. I am very new to Magento and figured this would be the best way to do it. After exporting it to my WAMP server via FTP, I noticed that when trying to log into Admin or open the home page I get

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 1489781624

Looking at the error report in var/report/ reveals this code.

a:5:{i:0;s:96:"SQLSTATE[HY000] [1045] Access denied for user 'avant_jonathan'@'localhost' (using password: YES)";i:1;s:1302:"#0 C:\wamp\www\includes\src\__default.php(53987): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 C:\wamp\www\includes\src\__default.php(54460): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 C:\wamp\www\includes\src\__default.php(52674): Varien_Db_Adapter_Pdo_Mysql->_connect()
#3 C:\wamp\www\includes\src\__default.php(53730): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#4 C:\wamp\www\includes\src\__default.php(54566): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#5 C:\wamp\www\includes\src\__default.php(29302): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#6 C:\wamp\www\includes\src\__default.php(29243): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#7 C:\wamp\www\includes\src\Mage_Core_Model_Resource_Setup.php(141): Mage_Core_Model_Resource->getConnection('core_setup')
#8 C:\wamp\www\includes\src\Mage_Core_Model_Resource_Setup.php(234): Mage_Core_Model_Resource_Setup->__construct('core_setup')
#9 C:\wamp\www\includes\src\__default.php(20124): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#10 C:\wamp\www\includes\src\__default.php(20050): Mage_Core_Model_App->_initModules()
#11 C:\wamp\www\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#12 C:\wamp\www\index.php(87): Mage::run('', 'store')
#13 {main}";s:3:"url";s:6:"/admin";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

I wonder if either a) older files or modules from my old WAMP server are causing the error or b) not all the files copied over correctly. If anyone can help and even possibly help me understand how to read this report, that would be much appreciated. This is also one of my first few questions on StackExchange so if I can reword or add more to my question let me know, I'm excited to learn how to be a contributing member here as I know it will be a valuable resource.

Thanks in advance!

Foi útil?

Solução

Those error reports are stored in PHP's serialized format — you can unserialize them with code that looks something like this

$contents = file_get_contents('path/to/report');
$thing = unserialize($contents);
var_dump($thing);

If you do that, you'll get the items broken out into an array, making it a little easier to read

array(5) {
  [0] =>
  string(96) "SQLSTATE[HY000] [1045] Access denied for user \'avant_jonathan\'@\'localhost\' (using password: YES)"
  [1] =>
  string(1302) "#0 C:\\wamp\\www\\includes\\src\\__default.php(53987): Zend_Db_Adapter_Pdo_Abstract->_connect()\n#1 C:\\wamp\\www\\includes\\src\\__default.php(54460): Zend_Db_Adapter_Pdo_Mysql->_connect()\n#2 C:\\wamp\\www\\includes\\src\\__default.php(52674): Varien_Db_Adapter_Pdo_Mysql->_connect()\n#3 C:\\wamp\\www\\includes\\src\\__default.php(53730): Zend_Db_Adapter_Abstract->query(\'SET NAMES utf8\', Array)\n#4 C:\\wamp\\www\\includes\\src\\__default.php(54566): Zend_Db_Adapter_Pdo_Abstract->query(\'SET NAMES utf8\',"...
  'url' =>
  string(6) "/admin"
  'script_name' =>
  string(10) "/index.php"
  'skin' =>
  string(7) "default"
}

So, using the above, your error message (the first array index) is

SQLSTATE[HY000] [1045] Access denied for user \'avant_jonathan\'@\'localhost\' (using password: YES)

PHP is telling you it can't access the database with the configured information.

Open up

app/etc/local.xml

and look for the following section

<connection>
    <host><![CDATA[localhost]]></host>
    <username><![CDATA[avant_jonathan]]></username>
    <password><![CDATA[XXXXXXXXXX]]></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>

Change the host, username, and password to match your local settings.

For Magento to see your changes, you'll need to clear all the files out of /path/to/magento/var/cache/*, as Magento caches the contents of local.xml there.

Reload your home page (or any page except the error report page) and you should be good to go. (Or, good to move on to the next exception)

Outras dicas

This is a MySQL error telling you that the MySQL user avant_jonathan cannot connect to the database using the password provided on localhost.

  1. Check the settings in /app/etc/local.xml - is the MySQL username/password/host correct?
  2. Did you copy the database to your local WAMP environment too?
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top