Search

Recent Posts

Tags


« | Main | »

Updating WordPress (or other CMS) via SQL or ‘sed’

By Dale Reagan | March 9, 2010

Moving your WordPress site to a new URI?  If so, you will need to update the database entries that are specific to your new URI.  Some solutions to making global data changes:

Solution A – pre-import data massage

i.e.   sed -e 's/OLD_URI/NEW_URI/g' < MySql-Export.sql > MySql-Export.sql.mod
i.e. mysql -D  New_Database_name  -p < Mysql-Export.sql.mod

Solution B – post import SQL data massage

After importing the data (or if simply wishing to change the existing data) run SQL commands to make the changes, i.e. after starting Mysql (or using a tool PhpMyadmin) run the following (replacing ‘OLD_URI’ & ‘NEW_URI’ with your desired changes):

UPDATE wp_posts SET post_content = replace(post_content, ‘OLD_URI.files.wordpress.com/’, ‘NEW_URI/wp-content/uploads/’);
UPDATE wp_posts SET post_content = replace(post_content, ‘OLD_URI/wp-content/uploads/’, ‘NEW_URI/wp-content/uploads/’);
UPDATE wp_posts SET post_content = replace(post_content, ‘http://OLD_URI’, ‘http://NEW_URI’);

 I think that solution (A) is simpler (three steps: 1) export, 2) make changes via stream tools, 3) import) but solution (B) opens up the use o GUI tools like phpMyAdmin (a stellar tool) but typically will involve more UPDATE commands to get the same number of global changes.

Topics: Computer Technology, Wordpress Software | Comments Off on Updating WordPress (or other CMS) via SQL or ‘sed’

Comments are closed.


________________________________________________
YOUR GeoIP Data | Ip: 73.21.121.1
Continent: NA | Country Code: US | Country Name: United States
Region: | State/Region Name: | City:
(US only) Area Code: 0 | Postal code/Zip:
Latitude: 38.000000 | Longitude: -97.000000
Note - if using a mobile device your physical location may NOT be accurate...
________________________________________________

Georgia-USA.Com - Web Hosting for Business
____________________________________