Tips & Tricks

How to Find & Replace in MySQL

This tutorial will show you how to find and replace data in MySQL




Firstly you will need to login the mysql command line:

user@Box ~# mysql -u[username] -p[password] -h[hostname] database

Note: The hostname is not needed in the most cases. Also do not split -p and the password. If you do so it will ask you for the password one more time.


Now to find and replace the data in MySQL we need to execute the following command:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]’,'[string_to_replace]’);

That’s it!
Good luck!

Leave a Reply