Search and Replace in MySQL

Search and Replace in MySQL

Dzhuneyt Ahmed - Author of this post

By: Dzhuneyt Ahmed

Posted · 1 min read

Often your MySQL database is so large that if you want to find and replace a given entry, it will take days. This is when this simple snippet comes handy:

UPDATE [your_table_name] SET [your_table_field] = REPLACE([your_table_field], '[string_to_find]' , '[string_to_be_replaced]');

It will do a simple search and replace (just like Microsoft Word’s integrated function) on all the entries inside the specified table and field. Note that if your database has a lot of entries (e.g. millions), the pricess may take a few minutes or even time out.

Dzhuneyt Ahmed

Dzhuneyt

Helping teams build reliable cloud infrastructure — without the bloated bill.

Social

My Other Blogs

© 2026 Dzhuneyt Ahmed. All rights reserved.