Skip to content

MySQL

How To Do A Search & Replace On Your Website’s MySQL Database

For year’s I’ve used the WordPress Plugin SyntaxHighlighter to display code on my site.  Yesterday I ran into a huge problem. I wanted to change the way code is displayed on my site, which required changing hundreds of tags. SytaxHighlighter uses bash tags in shortcode format, but I needed to change all of those to standard pre tags. Not a fun night!

Every plugin a tried to do a search and replace didn’t work. I’m pretty sure the plugins weren’t able to handle the special characters properly. I hosed my database a few times along the way. Everything from screwed up Primary Key’s to bizarre Auto Increment problems. In the end, simplicity prevailed.

 

Quick Tip:  Don’t forget to create a backup of your database before making changes.  Just click the “Export” tab and select “Go!”

How To Search & Replace In MySQL

 

Most every website these days has PHPmyAdmin installed.  If not, it’s easy to do so (I’ll write a post on that soon). This is precisely the tool to do this job quickly and correctly.

Go ahead and log into PHPmyAdmin and select your database in the left-hand column.  Then select “SQL,” which is located in the top row of buttons.

Click Here To Continue Reading!