Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and replace entire mysql database

Tags:

mysql

i would like to do a find and replace inside an entire database not just a table.

How can i alter the script below to work?

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

Do i just use an asterix?

 update * set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); 
like image 730
Andy Avatar asked Jan 27 '11 22:01

Andy


People also ask

How do I find and replace in a database?

Go to phpMyAdmin and to the database you want to update. Select the required table name and go to “Search” tab. Click on the “Find and Replace” button. Enter the word to be found, and the replacement word.

How do I search an entire database in MySQL?

Find data across a MySQL connection by using the text search feature on any number of tables and schemas. From the schema tree, select the tables, schemas, or both to search and then right-click the highlighted items and click Search Data Table from the context menu.


1 Answers

sqldump to a text file, find/replace, re-import the sqldump.

Dump the database to a text file
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

Restore the database after you have made changes to it.
mysql -u root -p[root_password] [database_name] < dumpfilename.sql

like image 101
Dean Rather Avatar answered Sep 17 '22 13:09

Dean Rather