Search and Replace In Database

The Problem & Solution

We have to change brandname from BurnAlong to Burnalong but there are image file name was uploaded while migration process. Client focus on SEO meta

Solution:

Use MyKinstar tool replace text it will replace all content in the database, SEO meta description include image file name.

After the WordPress search and replace is complete, you need to change all image name to a new one.

Take a backup first, it is super easy, this way if you mess anything up you can re-import and start over.

2# Search and Replace Tool in MyKinsta

Click on the Tools tab, look for or scroll to the Search and replace section, and click on the Search and replace button:

Tips

For custom site configurations, or in the case of a plugin or theme error, the search and replace tool may not be able to complete. For these situations, we recommend trying the WP-CLI search-replace command with the –skip-plugins and/or –skip-themes flags as needed.

Using a single command to automatically find and replace a specific text, URL, or an image name in database.

3# Remote login to SSH at Kinsta to change all images name

1. Open a Terminal or iTrem on macOS or Linux

2. Connect to the server via the command line

In MyKinsta, you can find the details by selecting your site and finding the SFTP/SSH section of the Info screen.

Just copy SSH terminal command code and paste it into the command line. Once you’ve done that, you will be prompted for your password. Copy that from MyKinsta and you’ll be given access to your server. You’ll see a screen that looks something like this:
Kinsta SSH starting

Basic SSH Commands

				
					ls
cd public
ls
cd wp-content/uploads
ls
find . -name "*Yourtext*"
				
			

You’ll see a screen that looks something like this:

Screen Shot 2565 07 18 at 18.25.58

Find & Replace media file name in excel

We have to get list of all media that contains a directory name then copy it to edit in excel so it will be 3 columns
  • The mv Command
  • Find (source)
  • Replace (destination)
Screen Shot 2565 07 18 at 18.41.52

Copy all text and paste in Terminal hit Enter

				
					mv	./2022/04/BurnAlong-ExerciseDeviceImage-3-1-1024x674.jpg	./2022/04/Burnalong-ExerciseDeviceImage-3-1-1024x674.jpg
mv	./2022/04/BurnAlong-ExerciseDeviceImage-3-1.jpg	./2022/04/Burnalong-ExerciseDeviceImage-3-1.jpg
mv	./2022/04/BurnAlong-ExerciseDeviceImage-2-768x506.jpg	./2022/04/Burnalong-ExerciseDeviceImage-2-768x506.jpg
mv	./2022/04/BurnAlong-ExerciseDeviceImage-1024x674.jpg	./2022/04/Burnalong-ExerciseDeviceImage-1024x674.jpg
mv	./2022/04/Mockup-BurnAlong-Classes-Categories-WellnessHabits-opt-2-300x200.png	./2022/04/Mockup-Burnalong-Classes-Categories-WellnessHabits-opt-2-300x200.png
				
			
Credit to P' Joe

Done 🙂