◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Database → Run A Simple Search
How to run a simple search and replace in WordPress database
Running a search and replace in your WordPress database is easier than you think … but it’s also easy to mess up. Whether you’re updating URLs after a domain change or replacing text across hundreds of posts, the right method makes all the difference.
Let’s walk through safe and effective ways to perform a WordPress database search and replace, step by step.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
When and why to use search and replace in WordPress
Before changing anything in your database, know what situations call for this tool and what can go wrong. Common use cases include:
- Replacing old URLs after a domain migration or moving to HTTPS
- Updating shortcodes or embedded elements across posts
- Correcting typos or text errors site-wide
- Rebranding mentions of a product, service, or business name
- Replacing media paths or image URLs
- Bulk editing custom field values (especially with ACF or similar)
Search and replace risks
You need to be careful with search and replace because one wrong change—especially to serialized data—can break your entire WordPress site. Risks include:
- Breaking serialized data, which can corrupt themes or plugins
- Replacing content unintentionally in places you didn’t mean to impact
- Downtime or errors from changing URLs incorrectly
- Slow performance on large sites if using inefficient methods
Always back up your WordPress site first
Database edits are permanent. Backing up is non-negotiable.
How to back up safely
- Use a plugin like UpdraftPlus or BackWPup
- Create a manual database export via phpMyAdmin or your hosting control panel
- Store your backup in a secure offsite location (cloud, external drive, etc.)
Method 1: Use a WordPress plugin (easy and safe for most users)
Plugins make search and replace easier, especially when they handle serialized data automatically.
Recommended plugins
- Better Search Replace – Great for safe database changes, includes dry run
- WP Migrate Lite – Also handles URL replacements during migrations
- Search & Replace – Full-featured, but requires more caution
How to use Better Search Replace (step by step)
- Install and activate the plugin
- Go to Tools > Better Search Replace
- Enter the search string and replacement string
- Select which database tables to affect
- Check “Run as dry run” first to preview changes
- Uncheck dry run and execute the replacement when ready
Method 2: Run a search and replace with WP-CLI
WP-CLI is a command-line tool that lets you manage your WordPress site directly from the terminal, making tasks like updates, backups, and database changes faster and more efficient. This is the fastest method for developers or advanced users who have SSH access.
Benefits of using WP-CLI
- Safe handling of serialized data
- Extremely fast for large databases
- Can be scripted or automated
Example command
wp search-replace ‘old-domain.com’ ‘new-domain.com’ –dry-run
- Add –all-tables if needed
- Remove –dry-run once you’re confident in the result
Method 3: Use phpMyAdmin or Adminer (manual SQL query)
If you’re comfortable with SQL and need precise control over a specific table or field in your WordPress database, manual SQL gives you full control. It’s especially useful when plugins aren’t working or when you want to target something very specific without affecting serialized data, but it does require caution.
How to run a SQL search and replace
- Access phpMyAdmin via your hosting dashboard
- Select your database and click on the SQL tab
- Use a query like:
UPDATE wp_posts SET post_content = REPLACE(post_content, ‘old-text’, ‘new-text’); - Repeat for other tables/columns as needed
- Always test on a staging site first
Caution with serialized data
Avoid running manual SQL replacements on serialized data (like wp_options, wp_postmeta) unless you know how to handle it correctly.
Pro tips for safer replacements
Before you run any search and replace, keep these best practices in mind to avoid breaking your site or losing data.
- Always run a dry test before executing the real replacement.
- Use a staging site if possible, especially for major changes.
- Stick to plugins or WP-CLI when replacing values inside serialized arrays
- Document your changes for future reference
When to use a staging site instead
If your site has high traffic or mission-critical data, staging is the way to go. A staging site lets you test changes in a safe, private environment without affecting your live site or visitors. It’s the best way to catch errors, conflicts, or unintended results before they go public.
How to create a staging environment
Run and test your replacements safely before pushing changes live.
- Use your host’s one-click staging tool
- Clone your site manually using the Duplicator or WP Staging plugin
Getting started with search and replace in WordPress
A search and replace in your WordPress database can save hours of manual work—but only if done carefully. Knowing which method fits your skill level and your website setup is the key to avoiding problems.
Start with a plugin if you’re new to database changes, or use WP-CLI for fast, dev-level control. No matter which you choose, always back up and test first.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy. Liquid Web’s WordPress hosting options configure business-class servers and support plans specifically for WordPress websites.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
What is WordPress? →
A complete beginner’s guide to WordPress.org
How to change the WordPress database prefix →
Learn how to change your WordPress database prefix to enhance security and prevent SQL injection attacks.
WordPress development →
A beginner’s guide to WordPress dev, including hosting, admin basics, AI, and more