In this tutorial, I’ll show you a simple and effective method to globally replace URL or text in all posts in WordPress using a SQL Search and Replace query inside phpMyAdmin. This technique is extremely useful if you need to update a link, brand name, or any repeated phrase across your entire website without having to manually edit each post one by one.
Why Use SQL Search and Replace in WordPress?
There are many reasons you might want to perform a global text or URL replacement in WordPress:
- Updating old links – Example: replacing
http://oldlink.com
withhttps://newlink.com
. - Changing brand names – Rebranding your site and needing to swap out old company names.
- Correcting typos – Fixing a repeated spelling mistake across multiple posts.
- Migrating websites – Updating URLs after moving WordPress from one domain to another.
How to Replace Text or URLs in WordPress Using phpMyAdmin
- Log in to phpMyAdmin via your web hosting control panel (cPanel, Plesk, or equivalent).
- Select your WordPress database from the left-hand menu.
- Click on the SQL tab at the top.
- Paste the following SQL query into the SQL command box, replacing the sample URLs with your own values:
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'http://oldlink.com', 'http://newlink.com');
- Click “Go” to run the query and update your database.
That’s it! The SQL query will automatically replace every occurrence of the old URL or text within your WordPress post content, instantly updating all affected posts.
Important Notes and Best Practices
- Backup your database first! – Always create a full backup before making changes directly in phpMyAdmin.
- Use exact matches – Be precise with the text you replace to avoid accidentally overwriting unintended content.
- Search beyond posts – If you also need to update links in widgets, metadata, or custom fields, you may need to target other database tables such as
wp_postmeta
orwp_options
. - Case sensitivity – SQL
REPLACE()
is case-sensitive, so ensure you match text exactly.
Alternative Tools
If you prefer not to use phpMyAdmin directly, you can also use WordPress plugins such as Better Search Replace or WP Migrate DB. These tools provide a safer interface for performing global search and replace operations in WordPress.
Conclusion
Using a SQL Search and Replace query in phpMyAdmin is a powerful and efficient way to update text, URLs, or brand names across all your WordPress posts in just seconds. With proper backups and careful targeting, this method saves hours of manual editing and keeps your site content consistent and up to date.
Need more WordPress tips? Check out my guide on using SQL Search and Replace with phpMyAdmin for advanced techniques and troubleshooting.