What to change when you clone a production DB for the data

If you're copying over a Magento mysql database over to your local computer or to a dev server then there are a few consistent things you need to update/change so that you don't screw anything up and get it to work properly. Here is a checklist that I use when building dev servers.

If there's anything I've missed please comment below and I'll add it in!

Note: This checklist is just meant to assist you, use your own judgment to be as safe as possible with production data. Also, we're assuming here that you aren't using a prefix for your Magento tables.

The Checklist

The Magento table core_config_data contains config data for each store in your Magento installation.

  1. Update 'example.com' to 'example.dev' for all email addresses and urls in the store. This code is what we use:
    # Replace domain to example.dev
    UPDATE core_config_data 
    SET value = REPLACE(value, 'example.com', 'example.dev')
    WHERE value LIKE '%example.com%';
                    
  2. If your dev server doesn't have HTTPS...
    # Ensure HTTPS doesn't ever happen:
    UPDATE core_config_data 
    SET value = REPLACE(REPLACE(value, 'https://example.dev', 'http://example.dev'), 'https://www.example.dev', 'http://www.example.dev');
                    
  3. If you installed wordpress on the same DB and the database prefix is wp_ for wordpress tables:
    # IF YOU HAVE A WORDPRESS DB: Replace domain to example.dev for a wordpress installation if it exists.
    UPDATE wp_options 
    SET option_value = REPLACE(option_value, 'example.com', 'example.dev')
    WHERE option_value LIKE '%example.com%';
                    
  4. Udpate all customer email addresses to end in '.dev' so we don't accidentially email clients.
    # Apply ".dev" to the end of every email address.
    UPDATE `customer_entity`
    SET `email` = CONCAT(`email`, '.dev');
    UPDATE `sales_flat_order`
    SET `customer_email` = CONCAT(`customer_email`, '.dev');
    UPDATE `sales_flat_quote`
    SET `customer_email` = CONCAT(`customer_email`, '.dev');
    COMMIT;
    
                    
  5. Update app/etc/local.xml to point to the new database.
  6. If you're using wordpress in the /blog folder, update /blog/wp-config.php to point to the new server
  7. Clear all cache in wordpress and Magento
  8. Ensure payment gateways are pointing to sandboxes now and in test mode.
  9. Ensure Google Analytics (Google API settings) and any other analytics trackers are turned off
  10. If this is a public dev site you can add a simple password protection using these instructions.