Changes between Version 13 and Version 14 of MySql
- Timestamp:
- 06/20/11 16:15:15 (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MySql
v13 v14 18 18 }}} 19 19 20 == Basic dump and restore == 21 22 {{{ 23 MYDB=my_database_name 24 mysqldump $MYDB > mydb.dump 25 # destroy the database contents without dropping it to retain permissions 26 mysql $MYDB -BNe "show tables" | awk '{print "set foreign_key_checks=0; DROP TABLE `" $1 "`;"}' | mysql $MYDB 27 mysql $MYDB < mydb.dump 28 }}} 29 20 30 == Editing a dump file == 21 31 22 32 Sometimes it is handy to edit a database by editing the text dump file. 23 33 The `skip-extended-insert` dump format is easier to work with because 24 it puts one row on each line. Here is one way to do it: 34 it puts one row on each line. However, note that it is also much slower to 35 load than the default dump format. Here is one way to do edit a dump: 25 36 26 37 {{{ … … 32 43 nano new.dump 33 44 # destroy the database contents 34 mysql dump --add-drop-table --no-data $MYDB |grep DROP| mysql $MYDB45 mysql $MYDB -BNe "show tables" | awk '{print "set foreign_key_checks=0; DROP TABLE `" $1 "`;"}' | mysql $MYDB 35 46 mysql $MYDB < new.dump 36 47 }}}