MySQL Search and Replace

17 February, 2009 - 20:51

I've recently been moving a drupal site from one hosting environment to another, and the folder structure between the two within Drupal's sites/ is not identical. The main headache I was having was getting all nodes containing attached files and images to display properly. The Drupal image module is particularly unhelpful and unsympathetic about such moves.

A google search brought me to this page on urbanmainframe.com

update table_name set table_field = replace(table_field,'replace_that','with_this');

So to fix your file paths on a Drupal site that you're migrating that will ultimately live in a different directory within your sites folder,

UPDATE files SET filepath = replace( filepath, 'sites/all/files', 'sites/sitename.com/files' );

 

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Insert Flickr images: [flickr-photo:id=230452326,size=s] or [flickr-photoset:id=72157594262419167,size=m].

More information about formatting options