Support » Installing WordPress » Error establishing a database connection

  • I know this topic has come up a bazillion times but I’m quite ready to pull my hair out after trying every recommended fix I can find.

    I’m using MAMP, BlueHost and Chrome. I’ve downloaded WP 3.8 and put in MAMP–>htdocs–>wordpress. I created a database called “wordpress’ in phpMyAdmin in MAMP. I gave it all access and do not have a password on it (that I am aware of).

    Running http://localhost:8888/wordpress/ I am able to login and get the lovely HELLO WORLD! post / dashboard.

    Trying to go access results in the Error establishing a database connection. What am I doing wrong? Full config.php file is below, minus the password and config keys. As to the error screen’s questions:

    Are you sure you have the correct username and password? — Yes. I have also reset the password via the priveledges tab under PHPMyAdmin in MAMP. I used the generated password to update wp-config.php and re-ftp’ed it. No change in error message after refreshing the page. It also destroyed my localhost access so I changed it back to ‘root.’

    Are you sure that you have typed the correct hostname? Yes. I am using BlueHost and triple-confirmed the hostname is localhost.

    Are you sure that the database server is running? Yes. My original index.html page is still up and running.

    I also tried doing the WP install via BlueHost, but received an error page saying they couldn’t go further with a giant broken image that should have been a screenshot of the problem.

    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘wordpress’);

    /** MySQL database username */
    define(‘DB_USER’, ‘root’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘password-generated-from-phpMyAdmin’);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8’);

    /** The Database Collate type. Don’t change this if in doubt. */
    define(‘DB_COLLATE’, ”);

Viewing 10 replies - 1 through 10 (of 10 total)
  • Just a little clarification that might help sort it out…

    Your localhost installation on your mac has nothing to do with the installation at on BlueHost.

    The information in wp-config.php for must exactly match the database name and user credentials that were set up for the database on the site, not the local installation on your Mac. The two are not related, and share no data between them.

    You’ve also installed WordPress in your root directory ( at ) with a pre-existing html site. You can’t serve index.html and index.php from the same directory.

    Thanks ClaytonJames — I deleted the index.html page so that there is only the .php version. No luck — same database connection error. I’m positive the info on wp-config.php matches the information I used to set up the database on mysql via MAMP. Is there something else it could be?

    I’m positive the info on wp-config.php matches the information I used to set up the database on mysql via MAMP.

    What you set up on MAMP (which is on your computer) has nothing to do with what you set up (which is on your website). Did you set up a database on Not with MAMP but (probably) through a control panel on your web site?

    The wp-config.php that you upload to your website should contain the information on the database on your website — not the database you created on your local computer.

    Just leave your MAMP at your computer. It is localhost on your computer.
    The MAMP and its database are for WordPress installation on our computer.

    For your Bluehost hosting,

    1. First create a new database (with database name, user name & password) by using CPanel or PHPMYADMIN via bluehost administration panel.
    2. Then change wp-config.php with your new database name, new username, new password generated via Bluehost administration panel. Hostname may be localhost.

    @sarathlal N, @senff — thanks:

    So I deleted all existing databases on my CPanel via BlueHost. I created a new one and replaced the db name, password, and user name with the new credentials I created on the CPanel into wp-config.php and I still am getting the “Error establishing a database connection” problem. 🙁

    *Should note these were MySQL Databases.

    Are you doing a fresh installation?
    If so, Upload wordpress downloaded folder ( zip format) via cPanel, then unzip that folder.
    Copy the files & folders from that unzipped folder and move them in to your installation diorectory.
    Then navigate to your domain or http:// via browser, you can get wordpress installation screen.

    There is some simple steps & you can enter your DB details at there.
    Enter your correct DB name, username, password at there. If error is happening, you entered wrong details.

    If still you have doubts, read the below article.
    [link removed – that vendor is not GPL compliant – sorry not a good link to post here]

    I’m not familiar with Bluehost but sometimes the value for the hostname shouldn’t be ‘localhost’ but something more structural (even when the DB is on the same server), like or whatever.

    If you’re ABSOLUTELY sure that the info in wp-config.php that you uploaded to your server is correct and matches the database/user/password you created through cPanel, then perhaps you should contact Bluehost about this.



    Forum Moderator

    Is there a reason you aren’t using BlueHost’s one-click install for WP?

    I’d tried using BlueHost’s one-click install previously, but got an error message saying it couldn’t install, along with a broken screenshot (so I couldn’t see what the issue was). I tried BlueHost again last night, and that seemed to work after deleting the original index.html. I still cannot for the life of me figure out why the original installation would not work. BlueHost uses ‘localhost’ and I was indeed 1000% certain the info in wp-config.php was correct. Perhaps the next time I have to do this it will work out better.

    Thanks for the advice, everyone.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Error establishing a database connection’ is closed to new replies.