Support » Fixing WordPress » Database Connection Error

  • Hi,

    I received a database connection error, which is caused by a corruption of my wp-config file.

    I have two WordPress installations. One in and one in It seems like the configuration file for is now in the directory.

    If I leave it alone, the page will show up with the MySQL database information. However, if I attempt ot change the config file to point the the MySQL database associated with, I get a database connection error.

    Can someone help me reconnect to the MySQL database? Thanks for the help.


Viewing 15 replies - 1 through 15 (of 15 total)
  • $table_prefix is set correctly in each wp-config.php file?

    Files are in distinct folders for each installation?

    Additional resource:

    Hi Michael,

    Files are are distinct folders/directories. is in the root directory. is in the /health directory. If you look at both urls, you can see that both are accessing the same database at this time.

    $table_prefix is set to wp_ for both configs at this time.

    I should add that the username and password are the same for both databases.

    Thanks for the help.


    Are the database names different in each of the wp-config.php files?

    The database names are currently the same – xxxxx__wrdp2. This allows me to connect to the database. If I change to xxxxx_wrdp1, which is the database it should be associated with it, I get the database connection error. There must be a mismatch somewhere between the database name and directory – I think.

    Thanks for the help.


    Can you use something like phpMyAdmin to see both databases?

    Did something happen where one of the databases got moved to a different server (thus requiring wp-config.php be changed to reflect that)?

    Hi Michael,

    I verified that the database still exist via the cpanel of my host provider. It could be that I also corrupted some other php or config files in the root directory, which may now be out of synch with the wp_config file. Are there any other files that may contain information about the directory or database that needs to be in synch? For some reason it will allow to access wrdp2 but not wrdp1, if I make the simple change in the config file from wrdp2 to wrdp1.

    Appreciate the help.


    Keep in mind that the Site URI values are in the database. So if you have two different WP installs trying to use the same DB, only one of them is going to function.

    If you need to adjust the URI’s in the database for testing purposes, this little tutorial may help:

    Thanks HandySolo.

    Yes, I think this must be the problem. Somehow the URI values are out of synch. I will check out the tutorial and try to correct manually.

    Thanks for the tip.


    “Are there any other files that may contain information about the directory or database that needs to be in synch?”

    Not really. That’s why I asked if each blog had distinct directories. The wp-config.php (in each separate folder) is really the only thing that points to each database.

    Consider renaming one of the wp-config.php files to something like to wp-config_hold.php and making sure the OTHER blog is working okay.

    Then switch it around and do the same with the other blog.

    Well I’m confused because I was under the impression there was two distinct databases. 😉

    Hi Michael,

    Yes, there are two distinct databases. As you can see, if you go to and, both are now accessing the same database.

    However, if I change the wp_config.php in the directory to wrdp1 instead of wrdp2, then it can no longer access the database and I get a database connection error. Something must be out of synch somewhere, but I cannot figure out what.




    I checked out the wrdp1 database. It is there, and all of the options are correct. For some reason, I cannot access it when I have wrdp1 in the config file, but I can access the wrdp2. The two databases should be configured exactly the same except for the database name.

    Thanks for any help.


    Looks like it is resolved. What did you do to fix the problem?

    Hi Michael,

    Well, I gave up trying to find all the files affected, so I called up Bluehost, and they restored the root files to the previous day. Lost some work, but everything is working now. Thanks for your help.


    Can’t understand how restoring ‘root files’ would cause you to loose work maybe except for uploads that might be stored in your root folder. Wonder if they also restored you database files?

    Oh well…thanks for the feedback.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Database Connection Error’ is closed to new replies.