WordPress GuideDatabase → 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:

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:

Always back up your WordPress site first

Database edits are permanent. Backing up is non-negotiable.

How to back up safely

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

How to use Better Search Replace (step by step)

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

Example command

wp search-replace ‘old-domain.com’ ‘new-domain.com’ –dry-run

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

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.

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.

Ready to get started?

Get the fastest, most secure WordPress.org hosting on the market.

Trust us to help you choose the ideal hosting solution

Loading form…