msyqldump

mysqldump进行mysql备份

示例

导出远程数据库

mysqldump -uroot -pxxx -hxxx  > xxx.sql

只导出结构(表,视图,函数)

 mysqldump  -uroot -pxxx -d -R dataname > xxx.sql

只导出数据

mysqldump  -uroot -pxxx -n dataname > xxx.sql

导出所有的表和数据(包含视图,函数)

mysqldump  -uroot -pxxx -a -R dataname > xxx.sql

只导出某个表的shuj

mysqldump  -uroot -pxxx  dataname table > xxx.sql

mysqldump 命令详解

我们可以选择备份所有数据库,某几个数据库,某一个数据库,某一个数据库中的某几个表,某一个数据库中的一个表;

可以选择是否备份 存储过程和函数,触发器,调度事件。

  1. 选择导出的数据库 和 表:

    -a, --all-databases

    Dump all the databases. This will be same as --databases with all databases selected.

    -B, --databases

    Dump several databases. Note the difference in usage; in this case no tables are given. All name arguments are regarded as database names. 'USE db_name;' will be included in the output.

  2. 选择是否导出 建库,建表语句,是否导出 表中的数据: -n, --no-create-db

    Suppress the CREATE DATABASE ... IF NOT EXISTS statement that normally is output for each dumped database if

    -t, --no-create-info

    Don't write table creation info. (不导出建表语句)

    -d, --no-data

    No row information. (不导出数据,有时我们仅仅需要导出表结构,也就是建表语句就行了)

  3. 选择是否导出 存储过程和函数,触发器,调度事件:

    -R, --routines

    Dump stored routines (functions and procedures). (导出存储过程和函数)

    --triggers

    Dump triggers for each dumped table. (Defaults to on; use --skip-triggers to disable.) (导出触发器)

    --skip-triggers

    不导出触发器

    -E, --events

    Dump events. 导出调度事件(根据备份的目的进行选择,如果是搭建slave,那么就不要导出events.)

  4. 指定不导出 某个库的某个表: --ignore-table=name

    Do not dump the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table. Each table must be specified with both database and table names, e.g., --ignore-table=database.table. (在导出数据库时,排除某个或者某几个表不导出)

  5. 按照 where 条件导出: -w, --where='where_condition'

转载于:https://my.oschina.net/u/3350266/blog/2049678

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值