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:
Get a new shared hosting account with unlimited number of MYSQL databases. SSD MYSQL hosting on a greatly discounted price – 90% OFF the regular price!