Support » Installing WordPress » The Usual: Error Establishing a Database Connection

  • I downloaded the install package and began following the famous 5-minute install insturctions. Unfortunately, I’m into my third hour. I consistently get that popular error message: “Error establishing a database connection”.

    Here’s what I’ve checked and double-checked:

    • Do my versions of MySQL and PHP meet WordPress’s minimum requrements? Yes.
    • Have I entered the database and user names correctly in both places? Yes.
    • Are database priveleges set correctly for my WordPress user account? Yep.
    • Should I be using instead of localhost for DB_HOST, as I do in MovableType? Maybe, but I’ve tried both and no joy.
    • Have I Googled for the past hour, looking for alternative explanations? Uh-huh.

    What am I missing?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    have you set up a MySQL database and assigned a user?

    …just asking…


    Who is your host? Or is this on your own server?

    If it’s hosted, are you sure that “localhost” is correct, and that there isn’t a different host name for the database server?

    Can you access the database using phpMyAdmin with the same username and password in your wp-config.php?

    Thanks for the replies. Yep, database set up and user created.

    It’s my own server, where I’ve been hosting MT for quite a few years. MT has always used instead of localhost–I tried them both and no joy.

    I can access the database using the same user name and password I created. DB.


    I also had trouble with mysql connection about an hour ago. I hate to admit it, but I made a real rookie mistake while trying to install wordpress.

    Maybe your having the same trouble I had.

    I made the mistake in the setting up of the congfig.php file.

    I entered my sql data in the wrong part of the form.
    See below:

    Here’s how I entered my data the first time:
    // ** MySQL settings ** //
    define(‘mysql_database’, ‘wordpress’); // The name of the database
    define(‘my_username’, ‘username’); // Your MySQL username
    define(‘*****’, ‘password’); // …and password
    define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value

    Do you see the mistake yet?
    I should have entered the data as below:

    // ** MySQL settings ** //
    define(‘DB_NAME’, ‘mysql_database’); // The name of the database
    define(‘DB_USER’, ‘my_username’); // Your MySQL username
    define(‘DB_PASSWORD’, ‘*****’); // …and password
    define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value

    Hope this helps.


    Joe: Thanks for that, but nope, I managed to avoid that one. I imagine I’ve made an entirely different one. Heh. DB.

    I’m having the same problem only I accidently murdered my wp-config.php file and now I can’t remember what my settings were (I was trying to delete a different blog and went into the wrong folder lol)

    Not sure what to do next

    Well for a great part of it, if you have cpanel or similar through your host, you access mysql databases section and that will give you the database name, and database username, and depending on cpanel type and version, usually you’ll also be able to see if it’s using “localhost”.

    Password you can’t find that way. If you absolutely do NOT remember the password, you can in the same mysql section, create a new user with a new password, then add that new user to the database, and put all THAT info in the wp-config.php file.


    I feel your pain. I just grappled with the same issue. I finally got it figured out, and here’s what I did – as usual, operator error.

    While getting my blog set up, I had to tweak my wp-config.php file a few times to get the DB_NAME, DB_USER, etc. set up correctly. With my server, they prefix the DB name and username with the name of your site (so “mylogin” for “myDb” becomes “myDb_mylogin”, etc.) During the process of figuring this out and uploading new wp-config.php files, I was actually FTP’ing my updated wp-config.php file into the wp-admin directory (where the admin.php file lives), rather than into the “root” directory of the blog, which is one level higher. All my tweaks were going into the wrong directory, leaving my original (invalid) config file unchanged. Once I updated the correct “wp-config.php” file in the root of my blog, it worked like a charm. Five-minute-plus-twelve-hour-setup complete.

    Hope this helps.

    Thanks for the help, but I got the issue resolved using a local braniac. DB.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘The Usual: Error Establishing a Database Connection’ is closed to new replies.