Hey everyone. I recently went through the exact same problem. My situation is slightly different so my solution may not apply (exactly as I say), but it’s another thing to check out. I’ve installed MAMP and am planning to do my development prior to paying for a webhost and turning my wordpress site loose on the world. So, I was installing wordpress locally after installing MAMP on my iMac.
The Error (database error) – I started the famous 5 minute install and could never make it past the “Setup configuration file” page. You know, the page where you enter your database connection details. I would fill it out, click submit, and I’d get the error page saying I had something wrong with my DB name, username, or password. If I tried to manually create the config file I’d get the bold black lettered page “failed to establish a database connection.”
Every resource I found said the same thing, you have either misspelled the dbname, db user id, or the password or your database server was down. I didn’t have any of those problems – but I was still getting the same database connection error.
My real Problem – my database user preferences were not set up properly. I folllowed the “Create Database and a User” section to a “T.” There is a step that was not included in these detailed instructions. Somewhere in step two when you are creating your database user they failed to mention you may need to change the “Host” field to meet your requirements. They say nothing about changing this so I left it at it’s default value of “any host.” That was my problem.
The solution – change the database user login information “Host” field to “localhost” (for my uses). You may need to change this to the server-name (aka hostname) that you are using, for me, the “Any host” didn’t work. I made this change and bam! every thing worked. You can do this by loggin into the phpMyAdmin tool, selecting priveledges, clicking edit on your database user that your created, then near the bottom under the login information section change the host field to the hostname of your database server (you’ll find the hostname of your database server located at the very top of the main phpmyadmin page, just above the “Database” tab). In my case it’s “localhost.” I changed the host field to “localhost” and this solved my problem.
I was then able to continue with the install and get my wordpress site up and running in my test environment.
Good luck.