Use this SQL script when changing domains on a WordPress site. Whether you’re moving from an old domain to a new domain or you’re changing from a development domain to a production domain this will work.
- always backup your database.
- change the ‘oldsite.com’ and ‘newsite.com’ variables to your own.
- make sure your database prefix is “wp_”, if it’s not then you’ll want to go through and change the prefix in each line to whatever yours is.
- copy the modified variables and the queries and paste it into phpMyAdmin or, better yet, SequelPro and run it on your database. TEST. DONE.
Changelog: — updated queries to use variables instead of editing the urls in many different areas — commented out GUID and left as optional. shouldn’t reset those.
ref: codex.wordpress.org/Changing_The_Site_URL#Important_GUID_Note