H
10Corp Premium Hosting

How to Replace Database Entries Using phpMyAdmin

Last Updated: 2025-01-01 2 min read

After migrating a website or changing your domain name, your database may still contain old URLs, file paths, or other outdated values. phpMyAdmin provides a straightforward way to search and replace these entries across your database.

When You Need Search and Replace

Common scenarios include:

  • Domain change: Replacing http://olddomain.com with https://newdomain.com
  • HTTP to HTTPS migration: Updating http:// references to https://
  • Staging to production: Replacing staging URLs with production URLs
  • Directory changes: Updating file paths after restructuring

Important: Always create a database backup before performing any search and replace operations. Incorrect replacements can break your website.

Method 1: Using phpMyAdmin’s Find and Replace

  1. Log in to cPanel and open phpMyAdmin.
  2. Select your database from the left sidebar.
  3. Click on the table you want to modify (e.g., wp_options, wp_posts).
  4. Click the Search tab.
  5. Click Find and replace (available in newer phpMyAdmin versions).
  6. Configure the replacement:
    • Search for: Enter the old value (e.g., http://olddomain.com)
    • Replace with: Enter the new value (e.g., https://newdomain.com)
    • Column: Select the column to search in, or choose all columns
  7. Click Go to preview matches.
  8. Review the matched results, then confirm the replacement.

Method 2: Using SQL Queries

For more control, use SQL commands directly via the SQL tab:

Replace in a Specific Column

UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://olddomain.com', 'https://newdomain.com')
WHERE option_value LIKE '%http://olddomain.com%';

Replace Across a Table

UPDATE wp_posts
SET post_content = REPLACE(post_content, 'http://olddomain.com', 'https://newdomain.com')
WHERE post_content LIKE '%http://olddomain.com%';

Common WordPress Tables to Update

TableColumns to Check
wp_optionsoption_value (especially siteurl and home)
wp_postspost_content, guid
wp_postmetameta_value
wp_commentscomment_content, comment_author_url

Important Warnings

  • Serialized data: WordPress and other CMS platforms store some data in serialized format. A simple SQL REPLACE can break serialized strings because the character count changes. For WordPress, consider using a dedicated tool like WP-CLI’s search-replace command or the Better Search Replace plugin, which handle serialized data correctly.
  • Case sensitivity: MySQL REPLACE is case-sensitive. Make sure your search term matches the exact case of the stored values.
  • Test first: Run a SELECT query with your search term before running UPDATE to see how many rows will be affected.

Verifying the Results

After performing the replacement:

  1. Browse your website to check that URLs, images, and links work correctly.
  2. Search the database again for the old value to confirm no instances remain.
  3. Clear your website’s cache if you use a caching plugin.

Database search and replace is a powerful operation — take the time to back up and verify your work to avoid unintended consequences.

Tags: cpanel hosting phpmyadmin database mysql migration

Still need help?

Our support team is available 24/7 to assist you.