mysql – search & replace HUGE databases

So!, I have with almost 3Gb… and I need to make a search & replace…
This looks the best way to me…

EXPORT FROM MYSQL > LINUX SEARCH & REPLACE > IMPORT TO MYSQL

Dump database to text file

mysqldump -u user -p databasename > ./db.sql

Run sed command to find/replace target string

sed -i 's!oldString!newString!g' ./db.sql

Reload the database into MySQL

mysql -u user -p databasename < ./db.sql

As copied from http://stackoverflow.com/questions/11839060/find-and-replace-text-in-the-entire-table-using-a-mysql-query

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.