Database connection error. magento installation

First of all, check your database user name and password. Before you proceed to this step, you should have already set up the database in MySQL. You need to create a user and grant access privileges to that user.

Then check your MySQL server configuration. The default port number is 3306. However, your system admin might change it to something else. Or if you are using software packages such as MAMP/WAMP, the port number may be set to something other than 3306. In these cases, you need to explicitly put the port number in the Host field.

If all these are correct and you still have database connection error, you can try to use root account to access the database. If root works out, that means there are problems with the privileges in your MySQL settings. Although it is not recommended to use root account for future production deployment as it adds security risks to the server.


This is a pretty old question but I came across it recently and I hope this answer helps someone else. My issue came down to an old version of Magento on top of a new WAMP installation. Since MySQL 5.6.1, the have_innodb variable has been removed. However, the Magento installer checks for that variable and throws an error if it doesn't find it. If you actually check the exception log you'll see an error that the database server does not support InnoDB. Yet in the catch handler it only logs that exception and throws a generic "Database connection error" message.

The simplest fix, if you're sure your DB supports InnoDB, is to simply edit app\code\core\Mage\Install\Model\Installer\Db.php, find the checkDatabase method, and comment out the portion at the end of the try block that checks for have_innodb. Normally, I would not advocate editing core files, but this is only to get the installer working, so I'd say it's safe enough.


First create a db http://localhost/phpmyadmin

let assume DB Name : testdb

Configuration page db name : testdb username : root password : empty(don't enter any value)