Support » Installing WordPress » Error establishing a database connection

  • Resolved Robert Gadon


    I upgraded to WP v3.5 on 12/11/12. Since I am using the Twenty Ten template on my web site, I thought I would install a second version of WP in a subdirectory of my domain root to upgrade and expand site content. When the new site was built out, I planned to migrate the new version to the root directory, replacing the old site.

    I exported the web site database files (MySQL db: yogaman_wp1) to my home computer to save as a backup. I then added a subdirectory to my domain root called ‘wp2012’ and created a MySQL database called ‘yogaman_wp2012’. This is intended as the home for the new ‘Twenty Twelve’ based web site.

    I downloaded a copy of WP 3.5 to my computer, then uploaded the software to my web host via FTP. I mistakenly uploaded WP back to the domain root directory, overwriting the wp-config.php file for the ‘yogaman_wp1’ db (existing web site). Once I recognized the error, I corrected the reference values in the ‘wp-config.php’ file for the root directory. I uploaded WP v3.5 to the subdirectory ‘wp2012’ and changed the wp-config.php file for the subdirectory.

    I could not log in to WP in the root directory. At the suggestion of my web host, I changed the user name and PW for the MySQL db ‘yogaman_wp1’ (web site), then changed the values in the ‘wp-config.php’ file (root directory) to match. What came up at my domain login page ( was ‘Error establishing a database connection.

    I checked various threads in the Support forum, and someone suggested renaming the folder /wp-content/plugins to ‘/plugins.hold’ or ‘/plugins.1’. There was even a suggestion to disable all plugins through phpMyAdmin (I’m running v3.4.11.1)/wp_options/options_name but that function is not available to me. Should I just delete all the plugins for my web site and see if that makes a difference?

    I checked my url for malware using’s malware screen, and it came back clean.

    I have a help request in to my web host (, and am waiting for their reply. Anything else I should investigate to resolve the problem?

Viewing 4 replies - 1 through 4 (of 4 total)
  • “Error establishing a database connection” really means nothing more than that. It’s not a plugin problem, or a theme problem.

    You have a wrong database name, user, login or “localhost” in wp-config.php. (Or possibly wrong table prefix, if you changed that on the first site.) That’s it. Be sure you updated the passwords, users, database names, etc. in wp-config.php that you/the host changed.

    Thread Starter Robert Gadon


    Hi songdogtech,

    You’re certainly onto something. Everything in the wp-config.php file looks OK. On closer inspection, I realized that the MySQL database user name listed in the config file was not fully registered with the MySQL database itself. Duh! [For those of you following this thread, I went to cPanel X/Databases/MySQL Databases/ and reviewed the list of current databases. The MySQL database in question was listed, a user was registered, but not assigned. I went down to ‘Add User to Database’ and added the db_user named in the wp-config file to the actual database.

    When I go to my url: /, I now see a WP login screen, not the ‘Error establishing a database connection’ message. That’s progress. Now I can’t login to my site’s administrative panel!

    I went back to cPanel at my web host and went into phpMyAdmin at ‘yogaman_wp1 (name of my database)/wp_users, and edited the table to change the WP user name and PW. Reentered the new data on the wp-login page, and could not get in (the entry boxes shook). Changed wp_user & PW again at phpMyAdmin, and again, same result. Any suggestions?

    The password that’s stored in wp_user is NOT the password that you would type in. It’s a one-way hashed representation of the password, so if you type your password into that field and use that same password to log in, it will never match up.

    If your username and email address is correct now, use the ‘Lost your password?’ link to send out the password reset notice. Thats the best way to do it.

    Thread Starter Robert Gadon


    Thank you MM! Your suggestion worked! I’m astounded that the solution was right under my nose the entire time and I couldn’t see it. Through cPanel X, I visited phpMyAdmin/mydatabase/wp_users and viewed the user_password entry after I changed the WP password at / The PW entry was a long string of letters, numbers and symbols. When you wrote “one-way hashed representation of the password”, I assume that the string of letters, numbers, etc. in the phpMyAdmin db table was intended to cover up the actual WP password to which I changed. Anyway, problem resolved. Thank you again.

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