How to Find and Replace Text in the Database Using MySQL Queries from cPanel

How to Find and Replace Text in the Database Using MySQL Queries from cPanel

Are you wondering to replace any text from your WordPress blog posts? Suppose, you have added something, which has been updated, instead of editing each post, you may use the database.

Let’s say you have a website link on many blog posts, and you want to update it, searching and replacing from the database can solve your problem.

But, dealing with a database can be risky, so it’s necessary to backup your website and its database. You can either use a plugin or do it manually.

Even for searching replacing a text from a database, you can use a plugin, but if you’re an advanced user, you can use a MySQL query.

In this tutorial, you’re going to learn about the query and how you can update any text using phpMyAdmin, you may already know how you access it.

Well, nowadays, almost every web hosting company provides access to cPanel.

A Step By Step Process to Search and Replace Text

First of all, you should be familiar with cPanel. You’re going to see some screenshots, so if these are different from your cPanel, don’t worry, it’s because of every web hosting company uses a different design theme.

You can easily find the phpMyAdmin icon. Some company also offers the direct access to the database.

If you use Bluehost,Siteground, Hostinger, Inmotionhosting, JustHost, DreamHost, etc., for web hosting, you don’t need to worry. Even if you use any other web hosting, phpMyAdmin is standard.

Follow the steps.

Step 1:

Open your cPanel account and search for phpMyAdmin

. You can find it under the databases’ section.

How to Find and Replace Text in the Database Using MySQL Queries

Click to open.

Step 2:

A new tab opens up on your browser.

You can choose the database name from the left-side menu or click on databases

.

How to Find and Replace Text in the Database Using MySQL Queries

Choose the database name to open.

Step 3:

As you can see, there are many database tables.

Now, you need to click on the SQL option from the main navigation menu of phpMyAdmin

.

How to Find and Replace Text in the Database Using MySQL Queries

Step 4:

A box appears to run an SQL query. Let me show you the format of an SQL query

.

How to Find and Replace Text in the Database Using MySQL Queries

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

Now, for example, you want to replace something from your blog posts. Let’s say you want to search “blogging world” and replace it with “blogosphere,” the code becomes as follow.

update wp_posts set post_content =
replace(post_content, 'blogging world', 'blogosphere');

Click on the Go button, and you’re good.

Note: Changes to the database are irreversible, it’s better you keep a back on your computer.

If you’re wondering how to know the table name and the field name, let me give you an idea.

When you open the database, you can see many tables having “wp_” as the prefix; if you have changed it, the prefix may be different.

The point is that you can find out the table easily. Let me mention some names of tables.

  • wp_comments
  • wp_posts
  • wp_termeta
  • wp_options
  • Wp_users

To create an SQL query, you need to know the table and field name. You can see the field name after opening the table you want to edit.

Congrats, you have learned to search and replace text from your website’s database.

I Hope You Can Reduce Your Efforts by Using a MySQL Query

As I have already mentioned, such type of task is for techie people. If you don’t have any idea about MySQL, you should use a plugin; there are many free WordPress plugins available in the official repository.

I remember when I broke my website by copying and pasting a line of coding to the database. It’s better to take the necessary safety precautions.

Conclusion

WordPress database has quite a conventional structure, but for non-techie people, it can be scary. Depending on your expertise, you can choose either method.

Although, if you plan to replace anything from your blog posts, you can use the SQL query shown in the example above.

Check out these top 3 cPanel hosting services:

Hostinger
$2.99 /mo
Starting price
Visit Hostinger
Rating based on expert review
  • User Friendly
    4.7
  • Support
    4.7
  • Features
    4.8
  • Reliability
    4.8
  • Pricing
    4.7
HostArmada
$2.49 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.0
FastComet
$1.79 /mo
Starting price
Visit FastComet
Rating based on expert review
  • User Friendly
    4.7
  • Support
    5.0
  • Features
    4.8
  • Reliability
    4.5
  • Pricing
    5.0

How to Install MYSQL 8.0 and Create a Database on a CentOS 7 Linux VPS or Dedicated Server

MySQL is one of the mostly utilized open source database platform globally. This
3 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to Configure and Install Elastic Stack on Ubuntu 18.04

Elastic stack allows you to store the logs, It is integrated with web server It
4 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How To Change the Database Port for WordPress

This guide will help you on how to change the database port of your Wordpress we
1 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How To Examine And Repair A Database in PhpMyAdmin

Over the period of time, database can be corrupted and needs to repaired. This t
1 min read
Elizabeth Grom
Elizabeth Grom
Hosting Expert
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top