Title: Database connection errors
Last modified: August 21, 2016

---

# Database connection errors

 *  Resolved [j63](https://wordpress.org/support/users/j63/)
 * (@j63)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/database-connection-errors-2/)
 * I’m trying to get SharDB to work and followed the instructions in _readme.txt_.
   I now have the following databases:
 * `foo_bar_clone` – the old monolithic database (a clone of the live database on
   a dev machine)
    `foo_bar_global` `foo_bar_home` `foo_bar_vip1` through `foo_bar_vip4``
   foo_bar_00` through `foo_bar_ff`
 * _db-settings.php_ has the following settings at the top:
 *     ```
       define( 'DATACENTER', '' );
       $shardb_hash_length = 2;
       $shardb_prefix = 'foo_bar_';
       $shardb_dataset = 'global';
       $enable_home_db = true;
       $num_vipdbs = 4;
       $shardb_local_db = true;
       ```
   
 * I have one database server set up:
 * `add_db_server( 'global', 0, '', 1, 1, DB_HOST, DB_HOST, $shardb_prefix . 'global',
   DB_USER, DB_PASSWORD );`
 * _wp-config.php_ has not been modified except for `require()`ing _db-settings.
   php_.
 * The import script runs through and the databases are populated. After copying
   _db.php_ into _wp-content_ I can open individual blogs and they seem to work.
   However, when I try to do anything in the network admin I get an error page telling
   me that the database `wp_blogs` could not be found in `foo_bar_clone`.
 * Apparently WordPress still tries to use the old monolithic database and apparently
   it doesn’t work. Removing _db.php_ restores full functionality. I have made a
   mistake somewhere but I can’t spot it.
 * How can I figure out what went wrong? And is there an easy way to figure out 
   which databases the new database class is trying to talk to?
 * [https://wordpress.org/plugins/shardb/](https://wordpress.org/plugins/shardb/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Ron Rennick](https://wordpress.org/support/users/wpmuguru/)
 * (@wpmuguru)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/database-connection-errors-2/#post-5033388)
 * First, change
 * `$shardb_dataset = 'global';`
 * to something other than global.
 * Where did you add this code?
 * > add_db_server( ‘global’, 0, ”, 1, 1, DB_HOST, DB_HOST, $shardb_prefix . ‘global’,
   > DB_USER, DB_PASSWORD );
 * You do not need to add any DB registration code.
 * Did you edit the sample config lines in the db-settings.php or add your own below?
 *  Thread Starter [j63](https://wordpress.org/support/users/j63/)
 * (@j63)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/database-connection-errors-2/#post-5033398)
 * The `define()` and `add_db_server()` calls turned out to be unchanged from the
   original file. The other settings were written below the comment block describing
   the variables.
 * Changing `$shardb_dataset`‘s value didn’t seem to help. I still get the same 
   error except that I now also get a database error when opening blogs – WordPress
   now can’t find the `wp_site` table anymore. It’s definitely in the `foo_bar_global`
   database, though.
 * I tried `var_dump()`ing the `$db_servers` and `$db_ds_parts` variables at the
   end of _db\_settings.php_ but couldn’t find anything that seemed obviously wrong.
   Still I’ll describe it in case something is wrong and I’m not seeing it.
 * `$db_servers` is populated with two datasets, the `global` dataset containing
   exactly one entry (at `$db_servers['global'][0][0]`) and the `foo_bar` dataset
   containing one entry per non-global table, with incrementing `part`.
 * `$db_ds_parts` assigns databases to partitions, with `foo_bar_global` being assigned
   to `global_0` and the others to `foo_bar_(incrementing number)`.
 *  Thread Starter [j63](https://wordpress.org/support/users/j63/)
 * (@j63)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/database-connection-errors-2/#post-5033401)
 * Bizarrely enough the problem now resolved itself despite me not touching anything.
   Perhaps some cache-related issue that ended up with my browser confusing WordPress.
   Waiting seems to have helped.
 * Still, thanks for the support.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Database connection errors’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/shardb.svg)
 * [SharDB](https://wordpress.org/plugins/shardb/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shardb/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shardb/)
 * [Active Topics](https://wordpress.org/support/plugin/shardb/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shardb/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shardb/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [j63](https://wordpress.org/support/users/j63/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/database-connection-errors-2/#post-5033401)
 * Status: resolved