关于备份数据库的一些命令

backup & restore:

  • mysqldump -uroot -p1234 –no-create-db taobao awang_activity_link awang_shorturl awang_activity awang_channel awang_user_question | gzip > awang_activity_link.$(date +’%Y%m%d%H’).sql.gz
  • mysqldump -hhostname -uusername -ppassword db > backupfile.sql
  • mysqldump –add-drop-table -uusername -ppassword db > backupfile.sql
  • mysqldump … | gzip > backupfile.sql.gz
  • mysqldump … specific_table1 sepcific_table2 > …
  • mysqldump … –databases db1 db2  > …
  • mysqldump … –no-data –databases db1 db2 db3 > structurebackupfile.sql
  • mysqldump –all-databases > …
  • mysql -h… -u… -p… db < backupfile.sql
  • gunzip < backupfile.sql.gz | mysql … db
  • mysqldump … | mysql … -C db
  • —————————————————————-
  • 导出结构:
    mysqldump … -d –add-drop-table db > …
  • 导入数据库:
    • use $db
    • source $file
  • mysqldump:
    • –add-locks
    • –add-drop-table
    • –allow-keywords
    • –no-create-info
    • -c –complete-insert
    • -C –compress
    • -e –extended-insert
    • -# –dubug
  • 批量备份:
    • mysql -uroot -p1243 -T /tmp $db $table1 $table2 … –fields-enclosed-by=\” –field-terminated-by=,
  • 批量导入:
    • mysqlimport -uroot -p1234 $db $table1 $table2 .. –fields-enclosed-by=\” –field-terminated-by=,
  • mk-parallel-dump/mk-parallel-restore

发表评论