Syncing WordPress Databases

Filed Under (MySQL, Web Development) by Robert Green on 08-06-2009

Tagged Under :

Whenever I’m doing any WordPress development, I eventually have the need to sync the data between the current dev server, possibly a staging server, and a live server. What’s the easiest way to move a WordPress database between 2 servers?


Let’s start this example by saying that we have 2 servers: Dev and Live. Each server has a mostly identical WordPress installation and each server has it’s own database. In order to sync the initial database from Dev to Live the following steps may be used:

  1. Use PHPMyAdmin to export the Dev database as a file
  2. Use PHPMyAdmin to export the Live database as a file (this is a backup, just in case)
  3. Import the Dev Database into the Live Database using PHPMyAdmin
  4. Run the following 5 SQL commands in order to update the domain name in your site:
    UPDATE wp_multirss SET URL=REPLACE(URL,'Dev_Address','Live_Address');
    UPDATE wp_multirss SET Favicon=REPLACE(Favicon,'Dev_Address','Live_Address');
    UPDATE wp_posts SET post_content=REPLACE(post_content,'Dev_Address','Live_Address');
    UPDATE wp_posts SET guid=REPLACE(guid,'Dev_Address','Live_Address');
    UPDATE wp_options SET option_value=REPLACE(option_value,'Dev_Address','Live_Address');
  5. And now, as long as you’ve written all your relative links correctly inside of your content, you’re finished!

Once you have the initial transfer completed, future transfer are much simpler. Then you only need to complete the above steps by exporting, dropping, and importing the tables that are relevant to the changes that have been made. What tables are those? Honestly, it depends on what you have changed since last time. The best way to figure this out is to go to the Database Description over at WordPress.org to see what you need to move.


Happy migrating!

ISAPI Rewrite 3 with WordPress

Filed Under (PHP, Web Development) by on 06-05-2009

Tagged Under : , ,

If you’re using these 2 tools together, you have to make small effort in order to get rewriting working properly. 

  1. Do what it says here
  2. Open wp-includes/classes.php
  3. Go to line 158. You should see something like $req_uri = $_SERVER['REQUEST_URI'];
  4. Replace that with $req_uri = $_SERVER['HTTP_X_REWRITE_URL'];
  5. You’re good to go!