MySQL Search and Replace

If you would like to perform a Search and Replace in your MySQL Database without using plugins you can easily do that through phpMyAdmin, in this tutorial we will show how to perform that for WordPress Posts. The MySQL Search and Replace is particularly useful when changing the domain of your WordPress website.

Open your phpMyAdmin tool from your cPanel account

 

Navigate to the Database of your WordPress installation and select the `wpDbPrefix_posts` table

 

Note: If you’re not certain what your Database is you can find out that through your wp-config.php file

You should be able to see that the Column that we’ll need to edit is called `guid`

 

Click on the “SQL” tab on the top of your phpMyAdmin interface

MySQL Search and Replace Query for WordPress

UPDATE `wpqw_posts` SET guid = REPLACE(guid, 'https://oldUrl.com/', 'https://newUrl.com/') WHERE `guid` LIKE 'https://oldUrl.com/%';

Performing this to replace https://example.com to https://newExample.com makes the following changes to the database

 

You might want to replace another Column’s Data for your MySQL Database, not only limited to WordPress’ Posts

MySQL Search and Replace Query

UPDATE  `MySQL_Table` SET  `MySQL_Table_Column` = REPLACE(`MySQL_Table_Column`, 'oldString', 'newString') WHERE  `MySQL_Table_Column` LIKE 'oldString%';

When Should I use MySQL Search and Replace?

Doing a Search and Replace via SQL could be dangerous if you have links that you’re unaware of which shouldn’t be changed. You should Search and Replace only when you’re convinced that you have to change the text in your Database. You should always perform a Database backup before proceeding with any manual changes. This can easily be done through phpMyAdmin:

  • 0 Els usuaris han Trobat Això Útil
Ha estat útil la resposta?

Articles Relacionats

What is php.ini?

Php.ini is one of the essential configuration files in PHP. When PHP starts, this is the file it...

Do you have any setup or hidden fees?

UniqueVPS does not charge any additional or hidden fees. All web hosting solutions, extra...

How many subdomains can I create with UniqueVPS?

You are free to create as many subdomains as you wish and install different site-building...

What is a subdomain?

A subdomain is a domain name that is part of a main domain. It might be a separate website with...

How to access the phpPgAdmin to manage my PostgreSQL?

Accessing phpPgAdmin is very straightforward. It is neatly located in every customers’ cPanel but...

Powered by WHMCompleteSolution