[openingText]
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.
[/openingText]
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 [tool]cPanel[/tool].
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:
[step]
[stepImage]
Click to open.
[/step]
Step 2:
[step]
A new tab opens up on your browser.
[stepImage]
Choose the database name to open.
[/step]
Step 3:
[step]
As you can see, there are many database tables.
[stepImage]
[/step]
Step 4:
[step]
[stepImage]
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.
[/step]
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.



