WPBeginner

Beginner's Guide for WordPress

  • Blog
    • Beginners Guide
    • News
    • Opinion
    • Showcase
    • Themes
    • Tutorials
    • WordPress Plugins
  • Start Here
    • How to Start a Blog
    • Create a Website
    • Start an Online Store
    • Best Website Builder
    • Email Marketing
    • WordPress Hosting
    • Business Name Ideas
  • Deals
    • Bluehost Coupon
    • SiteGround Coupon
    • WP Engine Coupon
    • HostGator Coupon
    • Domain.com Coupon
    • Constant Contact
    • View All Deals »
  • Glossary
  • Videos
  • Products
X
☰
Beginner's Guide for WordPress / Start your WordPress Blog in minutes
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

WPBeginner» Blog» Tutorials» How to Find and Replace Text with One Click in your WordPress Database

How to Find and Replace Text with One Click in your WordPress Database

Last updated on April 21st, 2016 by Editorial Staff
209 Shares
Share
Tweet
Share
Pin
Free WordPress Video Tutorials on YouTube by WPBeginner
How to Find and Replace Text with One Click in your WordPress Database

Are you looking to do a mass search and replace in WordPress? Whether you want to find and replace a specific text, URL, or an image, you can easily do so by using a find and replace WordPress plugin or a simple SQL query. In this article, we will show you how to find and replace text in your WordPress database.

Find and replace text in WordPress database with just one click

When You May Need Find & Replace for WordPress Database?

Let’s suppose that you have added specific text or URL to a number of your posts. You don’t know which posts you have added that text to, but you do know that there are a lot of them.

Now you can manually search your site and edit every single post one by one. That’s going to take time and has a high chance of you missing some occurrences.

Using a single command to automatically find and replace will do the same thing but much quicker and efficiently.

There is one downside to it though. If you made a mistake, then you will not be able to undo it. Once you replace the text, it is gone. You will need to carefully type the text you are looking for and the text you want to replace it with.

Having said that, let’s see how you can easily find and replace text in your WordPress database.

Getting Started

As we mentioned earlier that the changes you make to your database will not be reversible. You need to take every precaution to make sure that you don’t lose data.

First you need to create a WordPress database backup. You can do that by using a WordPress backup plugin. Alternatively, you can also create a database backup using phpMyAdmin.

After creating the backup of your WordPress database, you can move on to run your find and replace commands.

Running Find and Replace with a WordPress plugin

If you are not familiar with code and don’t want to write a custom SQL query, then there is an easy to use find and replace WordPress plugin called Better Search Replace.

Better search replace plugin settings

It allows you to run search and replace commands from inside your WordPress admin area. We have a detailed guide on how to search and replace in WordPress with Better Search Replace plugin.

Running Find & Replace MySQL Query with phpMyAdmin

You can also use phpMyAdmin to find and replace text from your WordPress database.

First you need to login to cPanel dashboard of your WordPress hosting. Scroll down to the database section and then click on phpMyAdmin.

phpMyAdmin

The screenshot above is showing the cPanel dashboard on BlueHost. Your cPanel dashboard may look slightly different.

This will launch phpMyAdmin where you will need to click on your WordPress database name and then click on SQL.

Running SQL query in phpMyAdmin

You will need to enter your SQL query in this format:

update TABLE_NAME set FIELD_NAME =
replace(FIELD_NAME, 'Text to find', 'text to replace with'); 

For example, if you wanted to search for text in a WordPress post’s content, then you would write your query like this:

update wp_posts set post_content =
replace(post_content,'Text to find','text to replace with');

Click on the ‘Go’ button to continue.

PhpMyAdmin will run your SQL query and upon success it will show the number of rows affected by the query.

You can now visit your WordPress site to see your changes in action.

We hope this article helped you learn how to find and replace text with one click in your WordPress database. You may also want to see our beginner’s guide on WordPress database management with phpMyAdmin.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

209 Shares
Share
Tweet
Share
Pin
Popular on WPBeginner Right Now!
  • Checklist

    Checklist: 15 Things You MUST DO Before Changing WordPress Themes

  • How to Start Your Own Podcast (Step by Step)

    How to Start Your Own Podcast (Step by Step)

  • Google Analytics in WordPress

    How to Install Google Analytics in WordPress for Beginners

  • How to Properly Move Your Blog from WordPress.com to WordPress.org

About the Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Trusted by over 1.3 million readers worldwide.

The Ultimate WordPress Toolkit

18 Comments

Leave a Reply
  1. Chris says:
    Sep 17, 2019 at 9:28 pm

    Can do search and replace HTML code? I have snippets of (table td tr) code I would like to replace.

    Reply
    • WPBeginner Support says:
      Sep 18, 2019 at 9:58 am

      It would depend on where that code was added from, you should normally be able to edit the page that it is on for modifying the code.

      Reply
  2. Shahala says:
    May 23, 2019 at 7:09 pm

    Hey there! could you please tell me how can I do this find and replace in sql for a word only in specific language?
    I tried using language queries but din’t work out!
    I really appreciate any help towards this. Thank you

    Reply
    • WPBeginner Support says:
      May 24, 2019 at 10:14 am

      Unless I hear otherwise, we don’t have a language specific search at the moment sadly.

      Reply
  3. Saud Shah says:
    Jan 24, 2019 at 1:08 pm

    How can we change 2018 to 2019 in categories and page titles with this plugin or phpmyadmin

    Reply
    • WPBeginner Support says:
      Jan 24, 2019 at 3:06 pm

      For the post and page titles, you would search the wp_posts table but, for changing categories and their urls you would want to do that manually and create 301 redirects.

      Reply
  4. Aminu says:
    Jan 24, 2018 at 12:43 am

    please, how do you replace texts in posts title?

    Reply
  5. Vishal says:
    Jan 11, 2018 at 1:30 pm

    Thanks a lot for this. I was looking for the exact same solution.

    Reply
  6. Anang says:
    Jan 1, 2018 at 9:39 am

    Thanks a lot. It saves me hours of work.

    Reply
  7. RCdiy says:
    Mar 14, 2017 at 11:42 am

    I want to replace all instances of “OpenTx” with “OpenTX” but skipping URLs. So basically only what the viewer sees… How do I do this? I’ve installed both Search Replace and Better Search Replace but they also replace in the URLs…

    Reply
  8. Piter says:
    Jan 29, 2017 at 7:14 pm

    I tried plugins “Search $ replace” and “Better Search Replace” but there was no effect. Links in my posts was there. But…

    Thanks a lot for code metod, it works fine. It takes only few seconds.

    Reply
  9. samowal says:
    Oct 13, 2016 at 7:18 pm

    Thank you very much, man.

    Reply
  10. Peter says:
    Apr 24, 2016 at 4:32 pm

    You already wrote an article about this last year: https://www.wpbeginner.com/plugins/search-and-replace-plugin-for-wordpress-database/ :)

    Reply
    • WPBeginner Support says:
      Apr 25, 2016 at 5:04 pm

      Thanks for noticing :) This is actually a rewrite of an old article that only showed the code method. We decided to add the plugin method and more explanation to it.

      Reply
  11. KMurphy says:
    Apr 22, 2016 at 8:09 am

    Is this something that would work in migrating a site – to change the DB urls to a new location?

    Reply
    • Kim Hopkins says:
      Apr 3, 2017 at 7:54 pm

      I just did this.

      Reply
  12. Oscar Estepa says:
    Apr 21, 2016 at 8:01 pm

    I’m not 100% sure but I’d say the SQL query can’t handle serialised data. If you search & replace your database using the suggested SQL query you’ll break the serialised data and get yourself into lots of troubles down the road like widgets not working, images dissappearing, broken javascript, etc.

    It’s well explained in this link http://davidcoveney.com/782/mysql-database-search-replace-with-serialized-php/

    So better look for a plugin, script or tool which handles serialised data, like the suggested plugin Better Search Replace or the interconnectit script.

    Personally I use search and replace tool integrated in WP-CLI, in my experience it’s the best and fastest tool out there, never had a problem so far, tested in dozens of websites. For less savvy people, I’d recommend a plugin since WP-CLI is a terminal command tool and might not suite everyone.

    Reply
  13. Damien Carbery says:
    Apr 21, 2016 at 11:43 am

    I like internetconnect/it’s Database Search and Replace Script.

    Unlike the phpMyAdmin example in the article, it will search all fields. It will also do a dummy run.

    Reply

Leave a Reply Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

Over 1,320,000+ Readers

Get fresh content from WPBeginner

Featured WordPress Plugin
WP Mail SMTP logo
WP Mail SMTP
Fix WordPress email delivery issues. #1 SMTP plugin. Learn More »
How to Start a Blog How to Start a Blog
I need help with ...
Starting a
Blog
WordPress
Performance
WordPress
Security
WordPress
SEO
WordPress
Errors
Building an
Online Store
Useful WordPress Guides
    • 7 Best WordPress Backup Plugins Compared (Pros and Cons)
    • How to Fix the Error Establishing a Database Connection in WordPress
    • Why You Need a CDN for your WordPress Blog? [Infographic]
    • 30 Legit Ways to Make Money Online Blogging with WordPress
    • Self Hosted WordPress.org vs. Free WordPress.com [Infograph]
    • Free Recording: WordPress Workshop for Beginners
    • 24 Must Have WordPress Plugins for Business Websites
    • How to Properly Move Your Blog from WordPress.com to WordPress.org
    • 5 Best Contact Form Plugins for WordPress Compared
    • Which is the Best WordPress Popup Plugin? (Comparison)
    • Best WooCommerce Hosting in 2021 (Comparison)
    • How to Fix the Internal Server Error in WordPress
    • How to Install WordPress - Complete WordPress Installation Tutorial
    • Why You Should Start Building an Email List Right Away
    • How to Properly Move WordPress to a New Domain Without Losing SEO
    • How to Choose the Best WordPress Hosting for Your Website
    • How to Choose the Best Blogging Platform (Comparison)
    • WordPress Tutorials - 200+ Step by Step WordPress Tutorials
    • 5 Best WordPress Ecommerce Plugins Compared
    • 5 Best WordPress Membership Plugins (Compared)
    • 7 Best Email Marketing Services for Small Business (2021)
    • How to Choose the Best Domain Registrar (Compared)
    • The Truth About Shared WordPress Web Hosting
    • When Do You Really Need Managed WordPress Hosting?
    • 5 Best Drag and Drop WordPress Page Builders Compared
    • How to Switch from Blogger to WordPress without Losing Google Rankings
    • How to Properly Switch From Wix to WordPress (Step by Step)
    • How to Properly Move from Weebly to WordPress (Step by Step)
    • Do You Really Need a VPS? Best WordPress VPS Hosting Compared
    • How to Properly Move from Squarespace to WordPress
    • How to Register a Domain Name (+ tip to get it for FREE)
    • HostGator Review - An Honest Look at Speed & Uptime (2021)
    • SiteGround Reviews from 4464 Users & Our Experts (2021)
    • Bluehost Review from Real Users + Performance Stats (2021)
    • How Much Does It Really Cost to Build a WordPress Website?
    • How to Create an Email Newsletter the RIGHT WAY (Step by Step)
    • Free Business Name Generator (A.I Powered)
    • How to Create a Free Business Email Address in 5 Minutes (Step by Step)
    • How to Install Google Analytics in WordPress for Beginners
    • How to Move WordPress to a New Host or Server With No Downtime
    • Why is WordPress Free? What are the Costs? What is the Catch?
    • How to Make a Website in 2021 – Step by Step Guide
Deals & Coupons (view all)
LiveChat logo
LiveChat Inc Coupon
Get a 30 day free trial and 30% OFF LiveChat, one of the best live chat service providers for WordPress users.
LearnDash
LearnDash Coupon
Get the lowest price on the best learning management system (LMS) plugin for WordPress.
Featured In
About WPBeginner®

WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi. The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).

Join our team: We are Hiring!

Site Links
  • About Us
  • Contact Us
  • FTC Disclosure
  • Privacy Policy
  • Terms of Service
  • Free Blog Setup
  • Free Business Tools
  • Growth Fund
Our Sites
  • OptinMonster
  • MonsterInsights
  • WPForms
  • SeedProd
  • Nameboy
  • RafflePress
  • Smash Balloon
  • AIOSEO

Copyright © 2009 - 2021 WPBeginner LLC. All Rights Reserved. WPBeginner® is a registered trademark.

Managed by Awesome Motive | WordPress hosting by SiteGround | WordPress Security by Sucuri.