I am trying to move a WordPress installation from one server to another one, including all of the SQL data, and the file-system data (photos,template files).
I just have a problem changing the URLs in the database, since I need to replace the new URL with the old one.
I would love to have some suggestions about how can I replace the URLs (maybe there's a rplace statement in SQL?)
Thanks in advance.
1) in your current server, go to phpMyAdmin and export your database
2) open the exported file in your fav code editor, find and replace in the whole document your ex base url (http://www.exdomain.com) with your new one (http://www.newdomain.com)
3) go to the new server, import the SQL file with phpMyAdmin
4) change DB user/pass/host in your wp-config.php
5) transfer via ftp all the files from the old server to the new one
and you should be done.
If you also change the directory path: delete your .htaccess and let Wordpress generate a new one updating the permalink options in the back-end.
This has always worked for me, I use to do this when it's time to move a localhost installation to the final production server.
Hope it helps.
You could simply dump the mySQL in a flat file and open it up in your favorite editor. Than do a find and replace for fully qualified domain name if you are literally change domains. That should take care of WordPress specific URL settings as well, so all your links in pages, posts, sidebars etc. will work. Also be sure to change the local path's recorded in the DB to reflect what the new ones will be as well.
Once your done import the mySQL file in to the new DB and have at it. If something when wrong in transit than you'll definitely know. :)
This is a really straight forwarded procedure with no frills but extremely detailed for newbies
Edit 5/16/2015
It's much better to use interconnectit.com WordPress Serialized PHP Search Replace Tool to find/replace URLs in the database and to correctly deserialize/reserialize that data. Doing a find/replace in a text dump or with the
UPDATE
queries below will break serialized data.Several easy ways: How to Move WordPress Blog to New Domain or Location » My Digital Life:
and others: How to Find and Replace Text in WordPress MySQL Database using SQL When Changing Domains » My Digital Life
Search RegEx « WordPress Plugins for grepping through posts and pages as a WP plugin-based way to replace image and other URLs in posts and pages.
And there's Moving WordPress « WordPress Codex.
One thing to be aware of is that WordPress stores some of it's data using serialised arrays (some plugins in particular, such as cforms, do this).
In instances where the site URL data may be serialised, simply updating the site URL text can change the length of data in the serialised string, corrupting the data and breaking things.
Interconnectit have a php script that takes serialisation into account when doing a search replace in the WordPress database. Github repo of the script here.
I have used this script in numerous WordPress migrations and it has been a lifesaver for me.
I think the guy is talking about hard links in his page/ post content. You need to apply @markratledge MySQL replace function link this...
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
This will replace all the links in you post/ page content...