Select Page

Search And Replace Using PHPmyadmin

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)

Check out more articles

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to https://dquinton.github.io/debian-install/config/ranger.html for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Adjust Trackpad Sensitivity XFCE

xinput set-prop "Elan Touchpad" "Synaptics Finger" 1 1 1 What are the values 1 1 1? This sets the sensitivity as close to the original ChromeOS as possible. Larger numbers will decrease sensitivity of various aspects. I never looked into which individual value...

Fireworks (Short Film)

https://vimeo.com/395077249 About the film Year: 2020 Director/DP: Tim Searfoss Writers: Matt Jones, Tim Searfoss Sound Mix: Matt Jones

Hosting Multiple Sites Using LocalWP

I've done a write-up on hosting local WordPress sites before, but I definitely prefer this method over the previous one. If you've never tried hosting multiple sites using LocalWP, then I'd encourage you to check it out. I've had really bad issues with it in the past,...

Looking for a place to host your next project or design?

Use this link to get your first 4 months of WP Engine for free: WP Engine – Plans (With 4 months free)