Find and replace entire mysql database

后端 未结 12 2184
走了就别回头了
走了就别回头了 2020-11-27 13:16

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          


        
12条回答
  •  不知归路
    2020-11-27 14:03

    This isn't possible - you need to carry out an UPDATE for each table individually.

    WARNING: DUBIOUS, BUT IT'LL WORK (PROBABLY) SOLUTION FOLLOWS

    Alternatively, you could dump the database via mysqldump and simply perform the search/replace on the resultant SQL file. (I'd recommend offlining anything that might touch the database whilst this is in progress, as well as using the --add-drop-table and --extended-insert flags.) However, you'd need to be sure that the search/replace text wasn't going to alter anything other than the data itself (i.e.: that the text you were going to swap out might not occur as a part of SQL syntax) and I'd really try doing the re-insert on an empty test database first.)

提交回复
热议问题