Select Your Database
To search and replace using phpmyadmin, first you’ll need to select and open the database you want to run the search and replace query on. Once you’ve selected it, you’ll see the tabs across the top of the screen change.
Execute Query
Click on the SQL tab at the top, and you’ll be greeted by a large textbox. This is where you can run your SQL queries like such:
UPDATE `table_name`
SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')
Keep In Mind When Using Search and Replace
You can only target one table at a time when running queries like this. It’s a good thing and a bad thing. Good because it prevents huge data loss across multiple tables with one wrong SQL query (there is no undo). Bad because it makes it kinda difficult to make large scale changes with a few keystrokes. Depends on your situation and what you’re trying to accomplish.
My Use Case
I was recently transitioning a WordPress site away from Divi and moving into a custom Gutenberg block theme. When I made the transition, there was lots of code embedded in all my posts that was left over from the Divi builder.
Various shortcodes left over indicated what kind of Divi module it used to be, what the layout was, what version of the builder I was using at the time, etc.
So rather than go in and manually clean up well over a hundred posts, I thought it was better to just run a search and replace query against the database to get rid of that extra code, making the transition a lot easier, and WordPress would have better luck converting existing posts over to Gutenberg blocks.
Using Search and Replace to Delete Stuff
With regard to the query outlined above, you can modify it to replace your target string with an empty one, which basically deletes it.
UPDATE `table_name`
SET `field_name` = replace(same_field_name, 'unwanted_text', '')
Using Search and Replace Across Multiple Tables
Since you’re not allowed to do this with a single SQL query, the best way to do something like this is to dump
the database and run a search and replace using your text editor of choice locally. Once completed, then you can just import that database into phpmyadmin, overwriting your existing database. (best to do all this locally before trying anything live)