// 3.备份数据库test1到/backup目录
[root@localhostjx ~]# mkdir -p /backup/mysql
[root@localhostjx ~]# mysqldump -uroot -predhat test1 >/backup/mysql/t1.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@localhostjx ~]# mysqldump -uroot -predhat -B test1 >/backup/mysql/t1_2.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
[root@localhostjx ~]# mysqldump -uroot -predhat -B test1 | gzip >/backup/mysql/t1_3.sql.gz
mysqldump: [Warning] Using a password on the command line interface can be insecure.
// 4.备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库
[root@localhostjx ~]# mysqldump --add-drop-table -predhat test1 > t2.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
// 5.直接将MySQL数据库压缩备份
[root@localhostjx ~]# mysqldump -uroot -predhat -B test1 | gzip > /backup/mysql/t3.sql.gz
mysqldump: [Warning] Using a password on the command line interface can be insecure.
// 6.备份MySQL数据库某个(些)表。此例备份student表
[root@localhostjx ~]# mysqldump -uroot -predhat test1 >/backup/mysql/t4.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
// 7.同时备份多个MySQL数据库(其他数据库素材自行准备)
[root@localhostjx ~]# mysqldump -uroot -predhat -B team test1 > /backup/mysql/t5.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
//8.仅仅备份数据库结构
[root@localhostjx ~]# mysqldump --no-data -uroot -predhat --databases test1 > /backup/mysql/t6.sq
mysqldump: [Warning] Using a password on the command line interface can be insecure.
// 9.备份服务器上所有数据库
[root@localhostjx ~]# mysqldump -uroot -predhat -A >/backup/mysql/all.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
//10.还原MySQL数据库
mysql> reset master;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
[root@localhostjx ~]# mysql -uroot -predhat -B test1 < /backup/mysql/t1_2.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
// 11.还原压缩的MySQL数据库
[root@localhostjx ~]# mysql -uroot -predhat -B test1 < /backup/mysql/t1_2.sql
mysql: [Warning] Using a password on the command line interface can be insecure.