一、备份命令
1、备份MySQL数据库的命令
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-hhostname-uusername-ppassword databasename>backupfile.sql
2、备份MySQL数据库为带删除表的格式
备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-–add-drop-table-uusername-ppassword databasename>backupfile.sql
3、直接将MySQL数据库压缩备份
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-hhostname-uusername-ppassword databasename|gzip>backupfile.sql.gz
4、备份MySQL数据库某个(些)表
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-hhostname-uusername-ppassword databasename specific_table1 specific_table2>backupfile.sql
5、同时备份多个MySQL数据库
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-hhostname-uusername-ppassword –databases databasename1 databasename2 databasename3>multibackupfile.sql
6、仅仅备份数据库结构
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump –no-data –databases databasename1 databasename2 databasename3>structurebackupfile.sql
7、备份服务器上所有数据库
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump –all-databases>allbackupfile.sql
二、还原命令
1、还原MySQL数据库的命令
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysql-hhostname-uusername-ppassword databasename<backupfile.sql
2、还原压缩的MySQL数据库
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->gunzip<backupfile.sql.gz|mysql-uusername-ppassword databasename
3、将数据库转移到新服务器
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->mysqldump-uusername-ppassword databasename|mysql –host=*.*.*.*-C databasename
总结
做好数据备份和还原,定好合适的备份策略,这是一个DBA所做事情的一小部分,万事开头难,就从现在开始吧!
PURGE {MASTER | BINARY} LOGS TO 'log_name' PURGE {MASTER | BINARY} LOGS BEFORE 'date' 用于删除列于在指定的日志或日期之前的日志索引中的所有二进制日志。这些日志也会从记录在日志索引文件中的清单中被删除,这样被给定的日志成为第一个...欢迎分享,转载请注明来源:内存溢出
评论列表(0条)