独立备份某个数据库的某个表操作:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
mysql> use mysql mysql> show tables; +---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | innodb_index_stats | | innodb_table_stats | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | servers | | slave_master_info | | slave_relay_log_info | | slave_worker_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 28 rows in set (0.00 sec) |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@Mysql ~]# /usr/local/mysql/bin/mysqldump -uroot -p'admin' -B mysql |gzip >/backup/mysql-$(date +%F).sql.gz #备份mysql数据库 [root@Mysql ~]# /usr/local/mysql/bin/mysqldump -uroot -p'admin' mysql user|gzip >/backup/user-tables-$(date +%F).sql.gz #压缩格式备份user表 [root@Mysql ~]# /usr/local/mysql/bin/mysqldump -uroot -p'admin' mysql servers >/backup/servers-tables-$(date +%F).sql [root@Mysql ~]# egrep -v "^$|^--|\*" /backup/servers-tables-2014-06-05.sql DROP TABLE IF EXISTS `servers`; CREATE TABLE `servers` ( `Server_name` char(64) NOT NULL DEFAULT '', `Host` char(64) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '', `Username` char(64) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '', `Port` int(4) NOT NULL DEFAULT '0', `Socket` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '', `Owner` char(64) NOT NULL DEFAULT '', PRIMARY KEY (`Server_name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'; LOCK TABLES `servers` WRITE; UNLOCK TABLES; [root@Mysql ~]# |
申明:本文由BYRD原创(基于Mysql5.6.16),未经许可禁止转载! SourceByrd's Weblog-https://note.t4x.org/database/backup-mysql-tables/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks