Magento Installation Problem - MySQL Access Denied

I was installing Magento on one of my commercial sites just to try it out and ran into this installation problem:

SQLSTATE[28000] [1045] Access denied for user ……# ‘root’@’localhost’ (using password: YES)
# Database connection error

The error message explains itself: there is a database connection issue and it’s probably because either your username and / or password don’t match or your account doesn’t have the privilege for this execution.

My question was exactly about that, too. “Why does it try to access MySQL database using the ‘root’ account? ”

I’m using shared hosting service from HostGator for this site, and I don’t have the root access to any of my MySQL databases. For example, my username for a DB would look like “ebiz_magento”, not ‘root’. This is a common case when you don’t have a dedicated server.

Something must’ve been messed up during my installation process because I couldn’t simply believe that they would’ve set the root account as default DB access for the installation.

So where is the file that has this incorrect DB access configuration?

After spending over 30 minutes, I found this file that contains the database access information.

It’s an XML file, ‘local.xml’ under ‘/app/etc/’.

<default_setup>
<connection>
<host><![CDATA[/tmp/mysql5.sock]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[]]></password>
<dbname><![CDATA[magento]]></dbname>
<active>1</active>
</connection>

Change the username, password and dbname appropriately.

After a couple of days later, I figured out why I had this problem. I had installed the software locally on my Windows using the root account for MySQL before I did on my server. I uploaded the files from that directory where it was configured to use the root account in ‘local.xml’.

When I checked the files freshly upzipped from the installation file, I found it doesn’t have the file ‘local.xml’.

1 Comment

  • By AbdulHakim Maina, February 2, 2010 @ 3:52 pm

    Thanks mate! You really saved me a lot of bother trying to db connection settings.

Leave a comment