MySQL find and replace data in drupal database

Case: in drupal I had to move a complete site (in single site configuration) from one server to another server (in multisite configuration).

All the files included in files/(single site configuration) were moved to a new directory sites/mydomain.com/files/ (multisite configuration).

At this point the path in the field filepath in the files table of the mysql database was not pointing to the correct place. I had to find and replace all values in filepath field to the new correct directory with the following mysql command:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');

In my example:

update files set filepath = replace(filepath, "files/fotos","sites/mydomain.com/files");

Post new comment

The content of this field is kept private and will not be shown publicly.
  • 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.

More information about formatting options

                                                           
88 88
88 ""
88
88 ,d8 88,dPYba,,adPYba, 88 88,dPYba,,adPYba,
88 ,a8" 88P' "88" "8a 88 88P' "88" "8a
8888[ 88 88 88 88 88 88 88
88`"Yba, 88 88 88 88 88 88 88
88 `Y8a 88 88 88 88 88 88 88

Enter the code depicted in ASCII art style.