Title: Copied Multisite, Database Connection Error
Last modified: August 20, 2016

---

# Copied Multisite, Database Connection Error

 *  [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/)
 * First, I’ve read all the way through all of these threads:
    [http://wordpress.org/support/topic/database-error-when-enabling-mutlisite?replies=32](http://wordpress.org/support/topic/database-error-when-enabling-mutlisite?replies=32)
   [http://wordpress.org/support/topic/upgraded-to-31-network-admin-foes-not-load](http://wordpress.org/support/topic/upgraded-to-31-network-admin-foes-not-load)
   [http://wordpress.org/support/topic/multisite-setup-failure?replies=12](http://wordpress.org/support/topic/multisite-setup-failure?replies=12)
 * I have an existing Multisite instance with 10 blogs, set up in the root of, let’s
   say: [http://example.com](http://example.com)
 * I copied the WordPress files to the /staging/ directory in my root.
 * I copied the entire database into a new database, and modified the new /staging/
   wp-config.php file to reflect the new database connection details. It works fine
   when MULTISITE is defined as “false”.
 * I ran some SQL queries to change all references of [http://example.com](http://example.com)
   to [http://staging.example.com](http://staging.example.com), which is the subdomain
   that points to the /staging/ directory. As long as `define( 'MULTISITE', true);`
   is set, when I load staging.example.com I get a plain “Error establishing database
   connection” message.
 * If I try to go to [http://staging.example.com/wp-admin](http://staging.example.com/wp-admin)
   I get a more WordPress UI driven error page, that says:
 * Error establishing database connection
    If your site does not display, please
   contact the owner of this network. If you are the owner of this network please
   check that MySQL is running properly and all tables are error free.
 * Could not find site staging.example.com. Searched for table 3v2Uwp_blogs in database
   xxx_xxx. Is that right?
 * What do I do now? Read the bug report page. Some of the guidelines there may 
   help you figure out what went wrong. If you’re still stuck with this message,
   then check that your database contains the following tables:
 * 3v2Uwp_users
    3v2Uwp_usermeta 3v2Uwp_blogs 3v2Uwp_signups 3v2Uwp_site 3v2Uwp_sitemeta
   3v2Uwp_registration_log 3v2Uwp_blog_versions
 * **** All of these tables exist in the database.
 * Please please please help! Developing on Multisite so far has been a nightmare.:-/

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/copied-multisite-database-connection-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/copied-multisite-database-connection-error/page/2/?output_format=md)

 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195017)
 * The db connection error comes up because it can’t find the blog in the db.
 * So, you missed some.
 * Multisite is more complicated than single site and requires more knowledge in
   general about servers and databases.
 * If it were me, I would not use a subdomain to stage a full TLD. I’d use a fake
   domain, or a spare domain, or a local one.
 *  Thread Starter [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195020)
 * Hi Andrea_r, thanks for your note.
 * I’ve read through every database table and done several find and replace functions.
   Anywhere that used to reference example.com now references staging.example.com,
   so far as the main site/blog is concerned. So all of the tables without numbers
   in them, that is.
 * I spent a day trying to set the site up on localhost and had a lot more problems
   with that than I’m having with this setup.
 * When you say “a full TLD”, what do you mean — and also, what do you mean by a
   fake domain?
 * Thanks very much for your help.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195023)
 * A full TLD = a full topleveldomain.
 * That is stage your code on testdomain.com rather than test.domain.com 🙂
 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195024)
 * > When you say “a full TLD”, what do you mean — and also, what do you mean by
   > a fake domain?
 * I mean a full domain, like example.net.
 * A fake domain would be one that lives n your computer’s hosts file. Like jason.
   local. Which you can them point literally anywhere but only you see it.
 * [http://wpmututorials.com/how-to/using-a-hosts-file/](http://wpmututorials.com/how-to/using-a-hosts-file/)
 *  Thread Starter [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195026)
 * Thanks, guys. I hadn’t thought of pointing the hosts file to the live site’s 
   domain and leaving the database records as-is. For some reason that sounds too
   easy to work! I may try that.
 * I am curious, though, why it shouldn’t work on a subdomain? And for the life 
   of me I can’t figure out why that would mean that it couldn’t connect to the 
   database, considering the database connection details don’t change no matter 
   what subdomain or subdirectory I’m in.
 * If the answer to this is “WP Multisite can’t handle what you’re trying to do”,
   I’d like to pursue contributing to the Codex to make that clear — but only if
   that’s really true.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195029)
 * It works. It’s just a bitch to move is all and I, for one, would never want to
   do it again unless you made me.
 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195030)
 * > If the answer to this is “WP Multisite can’t handle what you’re trying to do”,
   > I’d like to pursue contributing to the Codex to make that clear — but only 
   > if that’s really true.
 * I’m not saying it doesn’t work – it’s just trickier. there’s a difference. 😉
 * > And for the life of me I can’t figure out why that would mean that it couldn’t
   > connect to the database,
 * because the error message is wrong and needs to be fixed in core. 😉
 * “Could not find site staging.example.com.” was the big tip off.
 * (note: re codex contributions. you have a wp.org login. the codex uses the same
   one. you do not need permissions or clearance to contribute to the codex. you
   just go do it. 😉 )
 *  Thread Starter [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195031)
 * OK, so to get it to work, you need to adjust your database connection settings
   in wp-config.php, and track down every reference of original.com in the database
   tables and change them to subdomain.original.com — are there more steps?
 * It would seem to me that running the following SQL would make all of the necessary
   changes:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Just trying to track this down and understand the problem. Thanks for anyone’s
   help.
 *  Thread Starter [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195033)
 * [@andrea_r](https://wordpress.org/support/users/andrea_r/) — yes I know I can
   contribute to Codex but I wouldn’t do that unless I was sure of what I was contributing.
   🙂
 * As for the incorrect error message, that’s interesting, but I still can’t parse
   the tipoff of “Could not find site staging.example.com”, because that means that
   the database is trying to find the correct site. If that message said “Could 
   not find site example.com”, then I’d understand that it was looking for the wrong
   site.
 * I haven’t been able to dig deep enough into the Multisite execution flow to figure
   out what it’s using to look for the site staging.example.com, and why it wouldn’t
   be finding it. :-/
 *  [Andrea Rennick](https://wordpress.org/support/users/andrea_r/)
 * (@andrea_r)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195034)
 * I know you said you changed the url inthe db in all the non numbered tables. 
   can you check again? just do a search on the whole db.
 * and check wp-config.
    and check htaccess.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195035)
 * IIRC, there is more than one place where the setting is saved as domain.com (
   sans http and www). If you’re using www, it’s in a separate field in the table-
   row.
 *  Thread Starter [jasonrhodes](https://wordpress.org/support/users/jasonrhodes/)
 * (@jasonrhodes)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195040)
 * OK, I did a search on the whole db for anything containing “example.com”, and
   the only table I found that hadn’t been changed to “staging.example.com” in one
   form or another was the wp_usermeta table. Since I’m not yet logged in when I’m
   getting Database connection errors, I doubt this is the error, but for DUE DILIGENCE
   I changed my user id’s record appropriately.
 * The relevant piece of wp-config.php is:
 *     ```
       /** Turning on WordPress MU, new in 3.0 */
       define( 'WP_ALLOW_MULTISITE', false );
       define( 'MULTISITE', true );
       define( 'SUBDOMAIN_INSTALL', false );
       $base = '/';
       define( 'DOMAIN_CURRENT_SITE', 'staging.example.com' );
       define( 'PATH_CURRENT_SITE', '/' );
       define( 'SITE_ID_CURRENT_SITE', 1 );
       define( 'BLOG_ID_CURRENT_SITE', 1 );
       ```
   
 * and the .htaccess is straight from setting up Multisite instructions, with no
   absolute path references: [http://pastebin.com/ZfvRJBRk](http://pastebin.com/ZfvRJBRk)
 * That .htaccess file sits in the /staging/ directory with the rest of the WordPress
   files and directories.
 *  [superpotion](https://wordpress.org/support/users/superpotion/)
 * (@superpotion)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195190)
 * It doesn’t look like there’s been a satisfactory resolution. I have the same 
   problem, so will continue on this thread.
 * Scenario: developed site on `mysite.staging.com` then moved to `mysite.com` –
   copied all files, recreated db, global search and replace on all tables (but 
   not inline data) to change `mysite.staging.com` to `"www.mysite.com"` and edited
   wp-config, . When I launched site I got the home page, but custom menus didn’t
   work. When I clicked on a menu item I got **Error establishing database connection**,
   but when I tried to access mysite.com/wp-admin I got an error in a nice info-
   box:
 * > **Error establishing database connection**
   > If your site does not display, please contact the owner of this network. If
   > you are the owner of this network please check that MySQL is running properly
   > and all tables are error free.
   > Could not find site mysite.com. Searched for table wp_blogs in database mysite_wp.
   > Is that right?
   > What do I do now? Read the bug report page. Some of the guidelines there may
   > help you figure out what went wrong. If you’re still stuck with this message,
   > then check that your database contains the following tables:
   >  wp_users
   >  wp_usermeta wp_blogs wp_signups wp_site wp_sitemeta wp_registration_log
   > wp_blog_versions
 * I noticed that the error stated that it could not find `mysite.com` but in the
   search and replace I had made it `"www.mysite.com"`. So I globally replaced `"
   www.mysite.com"` for `mysite.com`. After that I could not even get the error 
   with the info box, just the ugly “Error establishing database connection” in 
   large black type!
 * I’ve been through everything here [http://codex.wordpress.org/Debugging_a_WordPress_Network](http://codex.wordpress.org/Debugging_a_WordPress_Network)
   and still no success!
 * I reverted everything back to `"www.mysite.com"`, and I get the ‘nice’ error 
   in an info box.
 * I can start all over again (I still have a working donor site), can anyone suggest
   a foolproof procedure?
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 4 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195191)
 * Don’t do a blanket search/replace.
 * YES you should change everythign in wp_x_posts
 * But you should NOT chnage it blindly in wp_x_options
 * I would do a blanket search/replaces for the posts, and then just search for 
   staging.example.com in what’s left and pay attention to what I’m editing.
 * You should only need to edit
    wp_blogs wp_site wp_sitemeta
 * and MAYBE
    wp_blog_versions
 *  [superpotion](https://wordpress.org/support/users/superpotion/)
 * (@superpotion)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/#post-2195192)
 * Thanks Ipstenu, I’ll be cautious. I wanted to deal with all the internal links
   to (images, etc) upfront. But I can live with the broken links, and once it’s
   running we can fix those.

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/copied-multisite-database-connection-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/copied-multisite-database-connection-error/page/2/?output_format=md)

The topic ‘Copied Multisite, Database Connection Error’ is closed to new replies.

## Tags

 * [connection](https://wordpress.org/support/topic-tag/connection/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [multisite](https://wordpress.org/support/topic-tag/multisite/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 19 replies
 * 4 participants
 * Last reply from: [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/copied-multisite-database-connection-error/page/2/#post-2195196)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
