Support » Installing WordPress » Error establishing a database connection!

  • Ive installed WordPress, fixed up a wp-config.php file with my stuff on there, but everytime i enter the index page, it comes up with this:
    Error establishing a database connection! This probably means that the connection information in your wp-config.php file is incorrect. Double check it and try again.
    Are you sure you have the correct user/password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?
    Ive tried and tried to fix it, but i cant figure out how.
    (btw im new to php)
    Please respond soon

Viewing 15 replies - 1 through 15 (of 26 total)
  • Joni


    Do you have a CPanel account? If so, go to the MySQL icon. Click there and you’ll see all your databases.
    When you created your database, MySQL probably prepended your user name to the database name. For example, if your ISP’s login is jsmith, and you created a database called wp1, then MySQL named it jsmith_wp1. Same thing for the user. If your user is jsmith, then MySQL named it jsmith_jsmith.
    Another GOTCHA is this: You must attach the database user to the database. This is not done automatically for you. Just use the dropdown boxes in the MySQL area to add user (whatever your username is) to your database (whatever your WP database is called), bearing in mind what I said above about the naming conventions.
    And of course, your wp-config.php file must reflect this info accurately.
    Hope this helps.

    I have the same problem. I’ve tried the different naming conventions. I’ve added my user to the database. I changed wp-config to reflect same. Any other suggestions? Does chmod need to be altered?

    Mark (podz)


    Support Maven

    I’m sure you’ll say I’m not answering you, but have you absolutely definitely done the ‘Another GOTCHA’ in the post above ?
    This step catches numerous people, and until it is done, nothing will work.
    Select user in first dropdwon, select database in second dropdown, then click ‘Add User to Db’ below it – you need to add the combination together so the server gets the right idea.

    I’m having this problem as well. Do you think it has anything to do with the fact that I uploaded the contents of the WordPress folder rather than just uploading the folder with the contents inside?

    Mark (podz)


    Support Maven

    3 anons…..2 saying you have the same problem ….
    Latest anon – no, that matters not. The problem is the database connection. It does not have the correct information.

    I too am having this difficulty. However, in my Cpanel I made sure that my username applies to my database. I made sure that I could even log into my database with my username and password. For some reason I’m still getting the “Error establishing database connection!” message.
    My database name is pokepc03_blog, and my username is pokepc03_carrie. This is what the wp-config.php code looks like (password not shown, of course):

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

    Do I need to define the host? That would simply be my domain name, right?

    Mark (podz)


    Support Maven

    // ** MySQL settings ** //
    define('DB_NAME','pokepc03_blog'); // The name of the database
    define('DB_USER','pokepc03_carrie'); // Your MySQL username
    define('DB_PASSWORD','****'); // ...and password
    define('DB_HOST','localhost'); // 99% chance you won't need to change this value

    is closer.

    Lol, I see. Thank you!

    is it possible that not only the pw has been changed on your MySQL server?

    The site was working, then I changed the server password and got the error message when I went to check on the site.
    I then updated the password in wp-config.php, but that didn’t resolve the problem. Everything else was identical. Given the advice I found here I tried changing the mySQL user names, but that hasn’t worked, either.

    OK, it’s a dumb question, but why did you change the pw (if everyhting worked well)?
    And: how and where did you change it? Is it a hosted environment or you are hosting your site?

    I changed the password because it was too easy to guess.
    I may not have actually change the MySQL password, I only changed the password in my cpanel server account, and someone told me that’s not necessarily the same thing as the database password. (But the wp-config.php file had the old cpanel password.)

    CPanel password = basically your pw to access your account at the hosting server. (At least this is how it works in my case, and I also use CPanel.)
    MySQL password = when you create a DB user in the CPanel database admin section, you are also prompted to associate a password to that user.
    Next. You have to add that user to the DB created.
    So, my guess is you’ve changed some other things, too, and they are not reflected in your config file.

    Moderator James Huff


    You should be able to find the DB_Name through whatever you used to set up your MySQL database. Ex: You webhost’s control panel, phpmyadmin, etc.

    Yeah, I’m pretty much 100% sure my db_name is correct. ickyfoot is my user name, wrdp1 is the name the database was given when I first installed wordpress earlier this year. I’m totally baffled…

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