WordPress: Change Word on all content sites with mysql

If you run a WordPress Blog or other CMS with MySQL Backend you can easy change one same word or expression on all content sites on the fly

  • Do a mysqldump at first of the current database

$ mysqldump -u username -p dbname > dbbackup.sql

  • Login to the MySQL server Console
  • Switch to the Database

mysql> use dbname;

  • run command for tests, lists touched posts

mysql> SELECT * FROM wp_posts WHERE (post_content LIKE '%expression%');

  • Run Replace code to pre, cause i use preformat text plugin for the copy & paste boxes

mysql> UPDATE wp_posts SET post_content = REPLACE ( post_content, 'code', 'pre');

  • exit
  • test results..