Find and Replace in PHPmyAdmin with MYSQL

Every so often I’m asked by clients to move their wordpress/ Joomla websites (which requires me to find and replace URLs) in PHPmyAdmin and MYSQL between hosts, and in doing so, I tend to test their new wordpress database installations using temporary URLs so that their current live website doesn’t experience any development down time which will cost time and money (unhappy visitors!).

Here’s a quick and easy way to find and replace content in MySQL using the PHPmyAdmin tool. I believe you can use this same command line in other Database editing tools but I’m throwing that… “I’m a designer, not a developer” card with this one as I only use PHPmyAdmin which suffices for my requirements.

I hope you find this as helpful as I do as I like to keep a little reminder for myself on how to do this.

Here’s how to find and replace in PHPmyAdmin with MySQL:

phpmyadmin login

  1. Log in to your phpMyAdmin account area.
  2. Within the left-hand side panel, select the database you wish find and replace in. (You may have multple websites/databases so make sure you choose the correct one.)
  3. Click on the ‘SQL’ tab at the top as pictured below.
    sql tab
  4. Copy and Paste the following code into the textarea remembering to replace your-table & yourtablefield with the specific tables you want to replace from within.
  5. Click ‘Go’ to action this script.
UPDATE `your-table` SET yourtablefield = replace(yourtablefield,"","");

Find and replace for wordpress example

Example used for replacing the domain/ URL with a new domain across all wordpress posts and pages. Follow the steps above and just copy this code instead remembering to change and to your own preferred choice.

This can be changed with anything you desire such as fixing typos or image filenames etc.

UPDATE `wp_posts` SET post_content = replace(post_content,"","");
Please note: I hold no responsibility with the above code and you implementing this yourself. If you are unsure on how this works please seek advice from your web host or similar. Playing with MySQL database tables can cause your website to break and not work. – You’ve been warned.

As always, I appreciate your comments and feedback. This find and replace script for phpmyadmin can be tailored for many uses.