`
openxtiger
  • 浏览: 148313 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Mysqldump的应用

 
阅读更多

--print-defaults        Print the program argument list and exit.

--no-defaults           Don't read default options from any option file.

--defaults-file=#       Only read default options from the given file #.

--defaults-extra-file=# Read this file after the global files are read.

  --all               Deprecated. Use --create-options instead.

  -A, --all-databases Dump all the databases. This will be same as --databases

                      with all databases selected.

  -Y, --all-tablespaces 

                      Dump all the tablespaces.

  -y, --no-tablespaces 

                      Do not dump any tablespace information.

  --add-drop-database Add a DROP DATABASE before each create.

  --add-drop-table    Add a DROP TABLE before each create.

  --add-locks         Add locks around INSERT statements.

  --allow-keywords    Allow creation of column names that are keywords.

  --character-sets-dir=name 

                      Directory for character set files.

  -i, --comments      Write additional information.

  --compatible=name   Change the dump to be compatible with a given mode. By

                      default tables are dumped in a format optimized for

                      MySQL. Legal modes are: ansi, mysql323, mysql40,

                      postgresql, oracle, mssql, db2, maxdb, no_key_options,

                      no_table_options, no_field_options. One can use several

                      modes separated by commas. Note: Requires MySQL server

                      version 4.1.0 or higher. This option is ignored with

                      earlier server versions.

  --compact           Give less verbose output (useful for debugging). Disables

                      structure comments and header/footer constructs.  Enables

                      options --skip-add-drop-table --skip-add-locks

                      --skip-comments --skip-disable-keys --skip-set-charset.

  -c, --complete-insert 

                      Use complete insert statements.

  -C, --compress      Use compression in server/client protocol.

  -a, --create-options 

                      Include all MySQL specific create options.

  -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.

  -#, --debug[=#]     This is a non-debug version. Catch this and exit.

  --debug-check       Check memory and open file usage at exit.

  --debug-info        Print some debug info at exit.

  --default-character-set=name 

                      Set the default character set.

  --delayed-insert    Insert rows with INSERT DELAYED.

  --delete-master-logs 

                      Delete logs on master after backup. This automatically

                      enables --master-data.

  -K, --disable-keys  '/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and

                      '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put

                      in the output.

  -E, --events        Dump events.

  -e, --extended-insert 

                      Use multiple-row INSERT syntax that include several

                      VALUES lists.

  --fields-terminated-by=name 

                      Fields in the output file are terminated by the given

                      string.

  --fields-enclosed-by=name 

                      Fields in the output file are enclosed by the given

                      character.

  --fields-optionally-enclosed-by=name 

                      Fields in the output file are optionally enclosed by the

                      given character.

  --fields-escaped-by=name 

                      Fields in the output file are escaped by the given

                      character.

  --first-slave       Deprecated, renamed to --lock-all-tables.

  -F, --flush-logs    Flush logs file in server before starting dump. Note that

                      if you dump many databases at once (using the option

                      --databases= or --all-databases), the logs will be

                      flushed for each database dumped. The exception is when

                      using --lock-all-tables or --master-data: in this case

                      the logs will be flushed only once, corresponding to the

                      moment all tables are locked. So if you want your dump

                      and the log flush to happen at the same exact moment you

                      should use --lock-all-tables or --master-data with

                      --flush-logs.

  --flush-privileges  Emit a FLUSH PRIVILEGES statement after dumping the mysql

                      database.  This option should be used any time the dump

                      contains the mysql database and any other database that

                      depends on the data in the mysql database for proper

                      restore. 

  -f, --force         Continue even if we get an SQL error.

  -?, --help          Display this help message and exit.

  --hex-blob          Dump binary strings (BINARY, VARBINARY, BLOB) in

                      hexadecimal format.

  -h, --host=name     Connect to host.

  --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.

  --insert-ignore     Insert rows with INSERT IGNORE.

  --lines-terminated-by=name 

                      Lines in the output file are terminated by the given

                      string.

  -x, --lock-all-tables 

                      Locks all tables across all databases. This is achieved

                      by taking a global read lock for the duration of the

                      whole dump. Automatically turns --single-transaction and

                      --lock-tables off.

  -l, --lock-tables   Lock all tables for read.

  --log-error=name    Append warnings and errors to given file.

  --master-data[=#]   This causes the binary log position and filename to be

                      appended to the output. If equal to 1, will print it as a

                      CHANGE MASTER command; if equal to 2, that command will

                      be prefixed with a comment symbol. This option will turn

                      --lock-all-tables on, unless --single-transaction is

                      specified too (in which case a global read lock is only

                      taken a short time at the beginning of the dump; don't

                      forget to read about --single-transaction below). In all

                      cases, any action on logs will happen at the exact moment

                      of the dump. Option automatically turns --lock-tables

                      off.

  --max_allowed_packet=# 

                      The maximum packet length to send to or receive from

                      server.

  --net_buffer_length=# 

                      The buffer size for TCP/IP and socket communication.

  --no-autocommit     Wrap tables with autocommit/commit statements.

  -n, --no-create-db  Suppress the CREATE DATABASE ... IF EXISTS statement that

                      normally is output for each dumped database if

                      --all-databases or --databases is given.

  -t, --no-create-info 

                      Don't write table creation info.

  -d, --no-data       No row information.

  -N, --no-set-names  Suppress the SET NAMES statement

  --opt               Same as --add-drop-table, --add-locks, --create-options,

                      --quick, --extended-insert, --lock-tables, --set-charset,

                      and --disable-keys. Enabled by default, disable with

                      --skip-opt.

  --order-by-primary  Sorts each table's rows by primary key, or first unique

                      key, if such a key exists.  Useful when dumping a MyISAM

                      table to be loaded into an InnoDB table, but will make

                      the dump itself take considerably longer.

  -p, --password[=name] 

                      Password to use when connecting to server. If password is

                      not given it's solicited on the tty.

  -P, --port=#        Port number to use for connection.

  --protocol=name     The protocol to use for connection (tcp, socket, pipe,

                      memory).

  -q, --quick         Don't buffer query, dump directly to stdout.

  -Q, --quote-names   Quote table and column names with backticks (`).

  --replace           Use REPLACE INTO instead of INSERT INTO.

  -r, --result-file=name 

                      Direct output to a given file. This option should be used

                      in MSDOS, because it prevents new line '\n' from being

                      converted to '\r\n' (carriage return + line feed).

  -R, --routines      Dump stored routines (functions and procedures).

  --set-charset       Add 'SET NAMES default_character_set' to the output.

                      Enabled by default; suppress with --skip-set-charset.

  -O, --set-variable=name 

                      Change the value of a variable. Please note that this

                      option is deprecated; you can set variables directly with

                      --variable-name=value.

  --single-transaction 

                      Creates a consistent snapshot by dumping all tables in a

                      single transaction. Works ONLY for tables stored in

                      storage engines which support multiversioning (currently

                      only InnoDB does); the dump is NOT guaranteed to be

                      consistent for other storage engines. While a

                      --single-transaction dump is in process, to ensure a

                      valid dump file (correct table contents and binary log

                      position), no other connection should use the following

                      statements: ALTER TABLE, DROP TABLE, RENAME TABLE,

                      TRUNCATE TABLE, as consistent snapshot is not isolated

                      from them. Option automatically turns off --lock-tables.

  --dump-date         Put a dump date to the end of the output.

  --skip-opt          Disable --opt. Disables --add-drop-table, --add-locks,

                      --create-options, --quick, --extended-insert,

                      --lock-tables, --set-charset, and --disable-keys.

  -S, --socket=name   The socket file to use for connection.

  -T, --tab=name      Create tab-separated textfile for each table to given

                      path. (Create .sql and .txt files.) NOTE: This only works

                      if mysqldump is run on the same machine as the mysqld

                      server.

  --tables            Overrides option --databases (-B).

  --triggers          Dump triggers for each dumped table.

  --tz-utc            SET TIME_ZONE='+00:00' at top of dump to allow dumping of

                      TIMESTAMP data when a server has data in different time

                      zones or data is being moved between servers with

                      different time zones.

  -u, --user=name     User for login if not current user.

  -v, --verbose       Print info about the various stages.

  -V, --version       Output version information and exit.

  -w, --where=name    Dump only selected records. Quotes are mandatory.

  -X, --xml           Dump a database as well formed XML.

 

 

1. mysqldump -uroot -R -p dbname > out.sql 导出数据和过程

 2. mysqldump -uroot -R -d -t -p dbname > out.sql 只导出过程

 

分享到:
评论

相关推荐

    mysqldump报错

    -bash: mysqldump: command not found问题解决

    MySQL错误代码以及出错信息对照大全

    * 0117:该应用程序所运行的 IOCTL 调用不正确 * 0118:校验写入的开关参数值不正确 * 0119:系统不支持所请求的命令 * 0120:该系统上不支持此功能 0121-0130:系统调用和文件处理相关错误 * 0121:标记已超时 * ...

    MysqldumpDropbox:做mysqldump并将其直接上传到Dropbox的简单方法

    MysqldumpDropbox 做mysqldump并将其直接上传到Dropbox的简单方法该脚本基于以下来源的源代码: #Installation从此存储库下载或克隆代码。 步骤1:登录到: : 第2步:要创建哪种类型的应用程序。 选择Dropbox API...

    mysql导入导出数据整理

    MySQL 是一个流行的关系型数据库管理系统,广泛应用于各种 web 应用程序中。作为一个数据库管理员,了解如何导入和导出数据是一项非常重要的技能。本文将详细介绍如何使用 mysqldump 工具来导出 MySQL 数据库的结构...

    mysql官方中文参考手册

    8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. mysqlshow-显示数据库、表和列信息 8.12. myisamlog:显示MyISAM日志文件内容 8.13. perror:解释错误...

    Linux中MySQL的异地自动备份.pdf

    Linux 操作系统作为当今最流行的开源操作系统之一,越来越多的应用于校园网应用中。然而,数据的意外丢失对于校园网应用来说是很大的损失。业务数据和校园网应用的日常业务运作唇齿相依。数据的丢失,即使是暂时性,...

    mysqldumpx:bash脚本的集合简化了MySQL数据库的部分备份

    MySQLDumpX bash脚本的集合简化了MySQL数据库的部分备份。...配置mysqldumpx的用户应该熟悉mysql附带的mysqldump实用程序。 示例中提供了带有所有可用选项示例的带注释的配置文件。 另外,还有可用的

    mysql数据迁移到mysql.rar

    MySQL是一款流行的关系型数据库管理系统,广泛应用于Web开发领域。当需要将数据从一个MySQL数据库迁移到另一个MySQL数据库时,您可以采用以下方法: 1.使用mysqldump命令导出数据 $ mysqldump -u username -p ...

    简单的MySQL备份与还原方法分享

    对于 MySQL 而言,最方便的方法可能就是用 phpMyAdmin 的导出、导入功能了,但如果你的数据库体积比较大,作为 Web 应用的 phpMyAdmin 可能会遭遇“超时”而操作失败。所以,学会在命令行模式下备份、还原数据库,...

    命令行模式下备份、还原 MySQL 数据库的语句小结

    对于 MySQL 而言,最方便的方法可能就是用 phpMyAdmin 的导出、导入功能了,但如果你的数据库体积比较大,作为 Web 应用的 phpMyAdmin 可能会遭遇“超时”而操作失败。所以,学会在命令行模式下备份、还原数据库,...

    MySQL导入.sql文件及常用命令

    MySQL 是一种关系型数据库管理系统,广泛应用于 Web 应用程序中。 MySQL 中有多种方式可以导入.sql 文件,并且提供了许多常用命令来管理和维护数据库。 一、导入.sql 文件 在 MySQL 中,可以使用 `source` 命令来...

    laravel-migration-snapshot:使用扁平化的数据库架构和迁移转储,可以简化并加速一次应用多个迁移

    使用扁平化的数据库模式转储和迁移来简化并加速一次应用许多迁移,其schema.rb类似于Rails的schema.rb 。 与mysql , pgsql和sqlite数据库驱动程序一起使用。 安装 您可以通过composer安装该软件包: composer ...

    rails_db_dump:用于万无一失的数据库转储的 Rake 任务

    添加 Rake 命令以转储和恢复应用程序的数据库。 委托常规转储实用程序,例如mysqldump和pg_dump 。 与它们不同的是,您不必记住任何正确的语法。 您也不必指定连接参数; 如果应用程序工作,转储程序也工作。 ...

    第15章MySQL数据库备份与还原.docx

    数据库系统原理及 MySQL 应用教程中,备份和恢复策略是非常重要的,因为数据库中的数据可能会由于各种原因而丢失或被破坏,例如计算机硬件故障、计算机软件故障、自然灾害、盗窃、病毒、人为误操作等。为了保证...

    mysql导入大容量.sql脚本文件方法

    MySQL 是一个流行的关系数据库管理系统,广泛应用于各种 web 应用程序中。随着数据量的增加,数据库的容量也在逐渐增加,对于大容量 SQL 脚本文件的导入变得尤为重要。本文将介绍如何使用命令行程序导入大容量 SQL ...

    某集团数据库系统维护管理措施.doc

    备 " " "储则为第三个"ak "份命令脚本:mysqldump -" " "盘符) " "-uroot -proot -R " " " " "DBname>F:\ " " " " "SangemWebDB_Bak\2011082" " " " "4.sql(编写Bat文件,建 " " " " "立计划任务进行定时备份 " " ...

    2017最新老男孩MySQL高级专业DBA实战课程全套【清晰不加密】,看完教程月入40万没毛病

    第二部 MySQL多实例安装与企业应用场景(10节) 22-MySQL数据库多实例介绍.avi 23-MySQL数据库多实例的优势和问题介绍.avi 24-MySQL数据库多实例的门户企业应用场景.avi 25-MySQL数据库多实例的多种配置方案介绍....

    大幅提升MySQL中InnoDB的全表扫描速度的方法

     一般来讲,大多数应用查询的时候都会用索引,查找很少的几行数据(主键查找或百行内的查询),但有时候我们需要全表查询。典型的全表扫描就是逻辑备份 (mysqldump) 和 online schema changes( 注:在线上对大表 ...

    xtrabackup备份还原MySQL数据库

    Xtrabackup可以解决mysqldump存在的上述的一些问题,生产环境应用的也会更多一些。 本文简单测试一下Xtrabackup对MySQL数据库的备份还原操作。 本着先把功能先撸起来再深入细节的原则,粗略地实现了一个备份还原,并...

    personnel-v3:人事管理系统版本3

    mysqldump -u <username> -p <database> > dump.sql 将dump.sql文件放在db/dump/目录中。 Steam Web API密钥 用户通过Steam登录到该应用程序。 要启用此功能,您需要向其传递Steam Web API密钥。 您可以通过获得一...

Global site tag (gtag.js) - Google Analytics