您的位置:首页 > 数据库 > MySQL

mysqldump参数及使用时要注意的地方

2009-08-21 16:50 375 查看
mysqldump的时候要注意几点:

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

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

3.-c, --complete-insert

Use complete insert statements.
4.-Q, --quote-names Quote table and column names with backticks (`).

5.-F, --flush-logs

6.-B, --databases

7.-C, --compress

8. --master-data[=value]
Write the binary log filename and position to the output. This option requires the RELOAD privilege and the binary log must be enabled. If the option value is equal to 1, the position and filename are written to the dump output in the form of a CHANGE MASTER statement. If the dump is from a master server and you use it to set up a slave server, the CHANGE MASTER statement causes the slave to start from the correct position in the master binary logs. If the option value is equal to 2, the CHANGE MASTER statement is written as an SQL comment. (This is the default action if value is

omitted.) value may be given as of MySQL 4.1.8; before that, do not specify an option value.
The --master-data option automatically turns off --lock-tables. It also turns on --lock-all-tables, unless --single-transaction also is specified (in which case, a global read lock is acquired only for a short time at the beginning of the dump. See also the description for --single-transaction. In all cases, any action on logs happens at the exact moment of the dump.

9.--quote-names, -Q
Quote database, table, and column names within ''' characters. If the ANSI_QUOTES SQL mode is enabled, names are quoted within '"' characters. As of MySQL 4.1.1, --quote-names is enabled by default. It can be disabled with --skip-quote-names, but this option should be given after any option such as --compatible that may enable --quote-names.

10.--single-transaction

该选项在导出数据之前提交一个 BEGIN SQL语句,BEGIN 不会阻塞任何应用程序且能保证导出时数据库的一致性状态。它只适用于事务表,例如 InnoDB 和 BDB。本选项和 --lock-tables 选项是互斥的,因为 LOCK TABLES 会使任何挂起的事务隐含提交。要想导出大表的话,应结合使用 --quick 选项
11.-max_allowed_packet

Mysql 5.1 遇到的信息包过大问题 用客户端导入数据的时候,遇到 错误代码: 1153 - Got a packet bigger than 'max_allowed_packet' bytes 终止了数据导入。

  当MySQL客户端或mysqld服务器收到大于max_allowed_packet字节的信息包时,将发出“信息包过大”错误,并关闭连接。对于某些客户端,如果通信信息包过大,在执行查询期间,可能会遇到“丢失与MySQL服务器的连接”错误。

  客户端和服务器均有自己的max_allowed_packet变量,因此,如你打算处理大的信息包,必须增加客户端和服务器上的该变量。一般情况下,服务器默认max-allowed-packet为1MB

  如果你正在使用mysql客户端程序,其max_allowed_packet变量的默认值为16MB。要想设置较大的值,可用下述方式启动mysql

  mysql>mysql --max-allowed-packet=32M

  在my.ini也可以更改,需要重新启动mysql

  在my.ini加入[mysql]max_allowed_packet=16M

当然尽量避免如此大的数据包,才是治本之道。


本文出自 “我的《奋斗》” 博客,请务必保留此出处http://wangmukun.blog.51cto.com/651644/194372
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: