You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2229 lines
49 KiB

  1. '\" t
  2. .\" Title: \fBmysqldump\fR
  3. .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
  4. .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
  5. .\" Date: 04/06/2010
  6. .\" Manual: MySQL Database System
  7. .\" Source: MySQL 5.1
  8. .\" Language: English
  9. .\"
  10. .TH "\FBMYSQLDUMP\FR" "1" "04/06/2010" "MySQL 5\&.1" "MySQL Database System"
  11. .\" -----------------------------------------------------------------
  12. .\" * set default formatting
  13. .\" -----------------------------------------------------------------
  14. .\" disable hyphenation
  15. .nh
  16. .\" disable justification (adjust text to left margin only)
  17. .ad l
  18. .\" -----------------------------------------------------------------
  19. .\" * MAIN CONTENT STARTS HERE *
  20. .\" -----------------------------------------------------------------
  21. .\" mysqldump
  22. .\" dumping: databases and tables
  23. .\" backups: databases and tables
  24. .\" databases: dumping
  25. .\" tables: dumping
  26. .SH "NAME"
  27. mysqldump \- a database backup program
  28. .SH "SYNOPSIS"
  29. .HP \w'\fBmysqldump\ [\fR\fB\fIoptions\fR\fR\fB]\ [\fR\fB\fIdb_name\fR\fR\fB\ [\fR\fB\fItbl_name\fR\fR\fB\ \&.\&.\&.]]\fR\ 'u
  30. \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] [\fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItbl_name\fR\fR\fB \&.\&.\&.]]\fR
  31. .SH "DESCRIPTION"
  32. .PP
  33. The
  34. \fBmysqldump\fR
  35. client is a backup program originally written by Igor Romanenko\&. It can be used to dump a database or a collection of databases for backup or transfer to another SQL server (not necessarily a MySQL server)\&. The dump typically contains SQL statements to create the table, populate it, or both\&. However,
  36. \fBmysqldump\fR
  37. can also be used to generate files in CSV, other delimited text, or XML format\&.
  38. .PP
  39. If you are doing a backup on the server and your tables all are
  40. MyISAM
  41. tables, consider using the
  42. \fBmysqlhotcopy\fR
  43. instead because it can accomplish faster backups and faster restores\&. See
  44. \fBmysqlhotcopy\fR(1)\&.
  45. .PP
  46. There are three general ways to invoke
  47. \fBmysqldump\fR:
  48. .sp
  49. .if n \{\
  50. .RS 4
  51. .\}
  52. .nf
  53. shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItbl_name\fR\fR\fB \&.\&.\&.]\fR
  54. shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-databases \fR\fB\fIdb_name\fR\fR\fB \&.\&.\&.\fR
  55. shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-all\-databases\fR
  56. .fi
  57. .if n \{\
  58. .RE
  59. .\}
  60. .PP
  61. If you do not name any tables following
  62. \fIdb_name\fR
  63. or if you use the
  64. \fB\-\-databases\fR
  65. or
  66. \fB\-\-all\-databases\fR
  67. option, entire databases are dumped\&.
  68. .PP
  69. \fBmysqldump\fR
  70. does not dump the
  71. INFORMATION_SCHEMA
  72. database by default\&. As of MySQL 5\&.1\&.38,
  73. \fBmysqldump\fR
  74. dumps
  75. INFORMATION_SCHEMA
  76. if you name it explicitly on the command line, although currently you must also use the
  77. \fB\-\-skip\-lock\-tables\fR
  78. option\&. Before 5\&.1\&.38,
  79. \fBmysqldump\fR
  80. silently ignores
  81. INFORMATION_SCHEMA
  82. even if you name it explicitly on the command line\&.
  83. .PP
  84. To see a list of the options your version of
  85. \fBmysqldump\fR
  86. supports, execute
  87. \fBmysqldump \-\-help\fR\&.
  88. .PP
  89. Some
  90. \fBmysqldump\fR
  91. options are shorthand for groups of other options:
  92. .sp
  93. .RS 4
  94. .ie n \{\
  95. \h'-04'\(bu\h'+03'\c
  96. .\}
  97. .el \{\
  98. .sp -1
  99. .IP \(bu 2.3
  100. .\}
  101. Use of
  102. \fB\-\-opt\fR
  103. is the same as specifying
  104. \fB\-\-add\-drop\-table\fR,
  105. \fB\-\-add\-locks\fR,
  106. \fB\-\-create\-options\fR,
  107. \fB\-\-disable\-keys\fR,
  108. \fB\-\-extended\-insert\fR,
  109. \fB\-\-lock\-tables\fR,
  110. \fB\-\-quick\fR, and
  111. \fB\-\-set\-charset\fR\&. All of the options that
  112. \fB\-\-opt\fR
  113. stands for also are on by default because
  114. \fB\-\-opt\fR
  115. is on by default\&.
  116. .RE
  117. .sp
  118. .RS 4
  119. .ie n \{\
  120. \h'-04'\(bu\h'+03'\c
  121. .\}
  122. .el \{\
  123. .sp -1
  124. .IP \(bu 2.3
  125. .\}
  126. Use of
  127. \fB\-\-compact\fR
  128. is the same as specifying
  129. \fB\-\-skip\-add\-drop\-table\fR,
  130. \fB\-\-skip\-add\-locks\fR,
  131. \fB\-\-skip\-comments\fR,
  132. \fB\-\-skip\-disable\-keys\fR, and
  133. \fB\-\-skip\-set\-charset\fR
  134. options\&.
  135. .RE
  136. .PP
  137. To reverse the effect of a group option, uses its
  138. \fB\-\-skip\-\fR\fB\fIxxx\fR\fR
  139. form (\fB\-\-skip\-opt\fR
  140. or
  141. \fB\-\-skip\-compact\fR)\&. It is also possible to select only part of the effect of a group option by following it with options that enable or disable specific features\&. Here are some examples:
  142. .sp
  143. .RS 4
  144. .ie n \{\
  145. \h'-04'\(bu\h'+03'\c
  146. .\}
  147. .el \{\
  148. .sp -1
  149. .IP \(bu 2.3
  150. .\}
  151. To select the effect of
  152. \fB\-\-opt\fR
  153. except for some features, use the
  154. \fB\-\-skip\fR
  155. option for each feature\&. To disable extended inserts and memory buffering, use
  156. \fB\-\-opt\fR
  157. \fB\-\-skip\-extended\-insert\fR
  158. \fB\-\-skip\-quick\fR\&. (Actually,
  159. \fB\-\-skip\-extended\-insert\fR
  160. \fB\-\-skip\-quick\fR
  161. is sufficient because
  162. \fB\-\-opt\fR
  163. is on by default\&.)
  164. .RE
  165. .sp
  166. .RS 4
  167. .ie n \{\
  168. \h'-04'\(bu\h'+03'\c
  169. .\}
  170. .el \{\
  171. .sp -1
  172. .IP \(bu 2.3
  173. .\}
  174. To reverse
  175. \fB\-\-opt\fR
  176. for all features except index disabling and table locking, use
  177. \fB\-\-skip\-opt\fR
  178. \fB\-\-disable\-keys\fR
  179. \fB\-\-lock\-tables\fR\&.
  180. .RE
  181. .PP
  182. When you selectively enable or disable the effect of a group option, order is important because options are processed first to last\&. For example,
  183. \fB\-\-disable\-keys\fR
  184. \fB\-\-lock\-tables\fR
  185. \fB\-\-skip\-opt\fR
  186. would not have the intended effect; it is the same as
  187. \fB\-\-skip\-opt\fR
  188. by itself\&.
  189. .PP
  190. \fBmysqldump\fR
  191. can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it\&. Buffering in memory can be a problem if you are dumping large tables\&. To dump tables row by row, use the
  192. \fB\-\-quick\fR
  193. option (or
  194. \fB\-\-opt\fR, which enables
  195. \fB\-\-quick\fR)\&. The
  196. \fB\-\-opt\fR
  197. option (and hence
  198. \fB\-\-quick\fR) is enabled by default, so to enable memory buffering, use
  199. \fB\-\-skip\-quick\fR\&.
  200. .PP
  201. If you are using a recent version of
  202. \fBmysqldump\fR
  203. to generate a dump to be reloaded into a very old MySQL server, you should not use the
  204. \fB\-\-opt\fR
  205. or
  206. \fB\-\-extended\-insert\fR
  207. option\&. Use
  208. \fB\-\-skip\-opt\fR
  209. instead\&.
  210. .if n \{\
  211. .sp
  212. .\}
  213. .RS 4
  214. .it 1 an-trap
  215. .nr an-no-space-flag 1
  216. .nr an-break-flag 1
  217. .br
  218. .ps +1
  219. \fBNote\fR
  220. .ps -1
  221. .br
  222. .PP
  223. \fBmysqldump\fR
  224. from MySQL 5\&.1\&.21 cannot be used to create dumps from MySQL server 5\&.1\&.20 and older\&. This issue is fixed in MySQL 5\&.1\&.22\&. (\m[blue]\fBBug#30123\fR\m[]\&\s-2\u[1]\d\s+2)
  225. .sp .5v
  226. .RE
  227. .PP
  228. \fBmysqldump\fR
  229. supports the following options, which can be specified on the command line or in the
  230. [mysqldump]
  231. and
  232. [client]
  233. option file groups\&.
  234. \fBmysqldump\fR
  235. also supports the options for processing option files described at
  236. Section\ \&4.2.3.3.1, \(lqCommand-Line Options that Affect Option-File Handling\(rq\&.
  237. .sp
  238. .RS 4
  239. .ie n \{\
  240. \h'-04'\(bu\h'+03'\c
  241. .\}
  242. .el \{\
  243. .sp -1
  244. .IP \(bu 2.3
  245. .\}
  246. .\" mysqldump: help option
  247. .\" help option: mysqldump
  248. \fB\-\-help\fR,
  249. \fB\-?\fR
  250. .sp
  251. Display a help message and exit\&.
  252. .RE
  253. .sp
  254. .RS 4
  255. .ie n \{\
  256. \h'-04'\(bu\h'+03'\c
  257. .\}
  258. .el \{\
  259. .sp -1
  260. .IP \(bu 2.3
  261. .\}
  262. .\" mysqldump: add-drop-database option
  263. .\" add-drop-database option: mysqldump
  264. \fB\-\-add\-drop\-database\fR
  265. .sp
  266. Add a
  267. DROP DATABASE
  268. statement before each
  269. CREATE DATABASE
  270. statement\&. This option is typically used in conjunction with the
  271. \fB\-\-all\-databases\fR
  272. or
  273. \fB\-\-databases\fR
  274. option because no
  275. CREATE DATABASE
  276. statements are written unless one of those options is specified\&.
  277. .RE
  278. .sp
  279. .RS 4
  280. .ie n \{\
  281. \h'-04'\(bu\h'+03'\c
  282. .\}
  283. .el \{\
  284. .sp -1
  285. .IP \(bu 2.3
  286. .\}
  287. .\" mysqldump: add-drop-table option
  288. .\" add-drop-table option: mysqldump
  289. \fB\-\-add\-drop\-table\fR
  290. .sp
  291. Add a
  292. DROP TABLE
  293. statement before each
  294. CREATE TABLE
  295. statement\&.
  296. .RE
  297. .sp
  298. .RS 4
  299. .ie n \{\
  300. \h'-04'\(bu\h'+03'\c
  301. .\}
  302. .el \{\
  303. .sp -1
  304. .IP \(bu 2.3
  305. .\}
  306. .\" mysqldump: add-locks option
  307. .\" add-locks option: mysqldump
  308. \fB\-\-add\-locks\fR
  309. .sp
  310. Surround each table dump with
  311. LOCK TABLES
  312. and
  313. UNLOCK TABLES
  314. statements\&. This results in faster inserts when the dump file is reloaded\&. See
  315. Section\ \&7.2.21, \(lqSpeed of INSERT Statements\(rq\&.
  316. .RE
  317. .sp
  318. .RS 4
  319. .ie n \{\
  320. \h'-04'\(bu\h'+03'\c
  321. .\}
  322. .el \{\
  323. .sp -1
  324. .IP \(bu 2.3
  325. .\}
  326. .\" mysqldump: all-databases option
  327. .\" all-databases option: mysqldump
  328. \fB\-\-all\-databases\fR,
  329. \fB\-A\fR
  330. .sp
  331. Dump all tables in all databases\&. This is the same as using the
  332. \fB\-\-databases\fR
  333. option and naming all the databases on the command line\&.
  334. .RE
  335. .sp
  336. .RS 4
  337. .ie n \{\
  338. \h'-04'\(bu\h'+03'\c
  339. .\}
  340. .el \{\
  341. .sp -1
  342. .IP \(bu 2.3
  343. .\}
  344. .\" mysqldump: all-tablespaces option
  345. .\" all-tablespaces option: mysqldump
  346. \fB\-\-all\-tablespaces\fR,
  347. \fB\-Y\fR
  348. .sp
  349. Adds to a table dump all SQL statements needed to create any tablespaces used by an
  350. NDBCLUSTER
  351. table\&. This information is not otherwise included in the output from
  352. \fBmysqldump\fR\&. This option is currently relevant only to MySQL Cluster tables\&.
  353. .sp
  354. This option was added in MySQL 5\&.1\&.6\&.
  355. .RE
  356. .sp
  357. .RS 4
  358. .ie n \{\
  359. \h'-04'\(bu\h'+03'\c
  360. .\}
  361. .el \{\
  362. .sp -1
  363. .IP \(bu 2.3
  364. .\}
  365. .\" mysqldump: allow-keywords option
  366. .\" allow-keywords option: mysqldump
  367. \fB\-\-allow\-keywords\fR
  368. .sp
  369. Allow creation of column names that are keywords\&. This works by prefixing each column name with the table name\&.
  370. .RE
  371. .sp
  372. .RS 4
  373. .ie n \{\
  374. \h'-04'\(bu\h'+03'\c
  375. .\}
  376. .el \{\
  377. .sp -1
  378. .IP \(bu 2.3
  379. .\}
  380. .\" mysqldump: character-sets-dir option
  381. .\" character-sets-dir option: mysqldump
  382. \fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
  383. .sp
  384. The directory where character sets are installed\&. See
  385. Section\ \&9.5, \(lqCharacter Set Configuration\(rq\&.
  386. .RE
  387. .sp
  388. .RS 4
  389. .ie n \{\
  390. \h'-04'\(bu\h'+03'\c
  391. .\}
  392. .el \{\
  393. .sp -1
  394. .IP \(bu 2.3
  395. .\}
  396. .\" mysqldump: comments option
  397. .\" comments option: mysqldump
  398. \fB\-\-comments\fR,
  399. \fB\-i\fR
  400. .sp
  401. Write additional information in the dump file such as program version, server version, and host\&. This option is enabled by default\&. To suppress this additional information, use
  402. \fB\-\-skip\-comments\fR\&.
  403. .RE
  404. .sp
  405. .RS 4
  406. .ie n \{\
  407. \h'-04'\(bu\h'+03'\c
  408. .\}
  409. .el \{\
  410. .sp -1
  411. .IP \(bu 2.3
  412. .\}
  413. .\" mysqldump: compact option
  414. .\" compact option: mysqldump
  415. \fB\-\-compact\fR
  416. .sp
  417. Produce more compact output\&. This option enables the
  418. \fB\-\-skip\-add\-drop\-table\fR,
  419. \fB\-\-skip\-add\-locks\fR,
  420. \fB\-\-skip\-comments\fR,
  421. \fB\-\-skip\-disable\-keys\fR, and
  422. \fB\-\-skip\-set\-charset\fR
  423. options\&.
  424. .if n \{\
  425. .sp
  426. .\}
  427. .RS 4
  428. .it 1 an-trap
  429. .nr an-no-space-flag 1
  430. .nr an-break-flag 1
  431. .br
  432. .ps +1
  433. \fBNote\fR
  434. .ps -1
  435. .br
  436. Prior to MySQL 5\&.1\&.21, this option did not create valid SQL if the database dump contained views\&. The recreation of views requires the creation and removal of temporary tables and this option suppressed the removal of those temporary tables\&. As a workaround, use
  437. \fB\-\-compact\fR
  438. with the
  439. \fB\-\-add\-drop\-table\fR
  440. option and then manually adjust the dump file\&.
  441. .sp .5v
  442. .RE
  443. .RE
  444. .sp
  445. .RS 4
  446. .ie n \{\
  447. \h'-04'\(bu\h'+03'\c
  448. .\}
  449. .el \{\
  450. .sp -1
  451. .IP \(bu 2.3
  452. .\}
  453. .\" mysqldump: compatible option
  454. .\" compatible option: mysqldump
  455. \fB\-\-compatible=\fR\fB\fIname\fR\fR
  456. .sp
  457. Produce output that is more compatible with other database systems or with older MySQL servers\&. The value of
  458. \fIname\fR
  459. can be
  460. ansi,
  461. mysql323,
  462. mysql40,
  463. postgresql,
  464. oracle,
  465. mssql,
  466. db2,
  467. maxdb,
  468. no_key_options,
  469. no_table_options, or
  470. no_field_options\&. To use several values, separate them by commas\&. These values have the same meaning as the corresponding options for setting the server SQL mode\&. See
  471. Section\ \&5.1.8, \(lqServer SQL Modes\(rq\&.
  472. .sp
  473. This option does not guarantee compatibility with other servers\&. It only enables those SQL mode values that are currently available for making dump output more compatible\&. For example,
  474. \fB\-\-compatible=oracle\fR
  475. does not map data types to Oracle types or use Oracle comment syntax\&.
  476. .sp
  477. \fIThis option requires a server version of 4\&.1\&.0 or higher\fR\&. With older servers, it does nothing\&.
  478. .RE
  479. .sp
  480. .RS 4
  481. .ie n \{\
  482. \h'-04'\(bu\h'+03'\c
  483. .\}
  484. .el \{\
  485. .sp -1
  486. .IP \(bu 2.3
  487. .\}
  488. .\" mysqldump: complete-insert option
  489. .\" complete-insert option: mysqldump
  490. \fB\-\-complete\-insert\fR,
  491. \fB\-c\fR
  492. .sp
  493. Use complete
  494. INSERT
  495. statements that include column names\&.
  496. .RE
  497. .sp
  498. .RS 4
  499. .ie n \{\
  500. \h'-04'\(bu\h'+03'\c
  501. .\}
  502. .el \{\
  503. .sp -1
  504. .IP \(bu 2.3
  505. .\}
  506. .\" mysqldump: compress option
  507. .\" compress option: mysqldump
  508. \fB\-\-compress\fR,
  509. \fB\-C\fR
  510. .sp
  511. Compress all information sent between the client and the server if both support compression\&.
  512. .RE
  513. .sp
  514. .RS 4
  515. .ie n \{\
  516. \h'-04'\(bu\h'+03'\c
  517. .\}
  518. .el \{\
  519. .sp -1
  520. .IP \(bu 2.3
  521. .\}
  522. .\" mysqldump: create-options option
  523. .\" create-options option: mysqldump
  524. \fB\-\-create\-options\fR
  525. .sp
  526. Include all MySQL\-specific table options in the
  527. CREATE TABLE
  528. statements\&.
  529. .RE
  530. .sp
  531. .RS 4
  532. .ie n \{\
  533. \h'-04'\(bu\h'+03'\c
  534. .\}
  535. .el \{\
  536. .sp -1
  537. .IP \(bu 2.3
  538. .\}
  539. .\" mysqldump: databases option
  540. .\" databases option: mysqldump
  541. \fB\-\-databases\fR,
  542. \fB\-B\fR
  543. .sp
  544. Dump several databases\&. Normally,
  545. \fBmysqldump\fR
  546. treats the first name argument on the command line as a database name and following names as table names\&. With this option, it treats all name arguments as database names\&.
  547. CREATE DATABASE
  548. and
  549. USE
  550. statements are included in the output before each new database\&.
  551. .RE
  552. .sp
  553. .RS 4
  554. .ie n \{\
  555. \h'-04'\(bu\h'+03'\c
  556. .\}
  557. .el \{\
  558. .sp -1
  559. .IP \(bu 2.3
  560. .\}
  561. .\" mysqldump: debug option
  562. .\" debug option: mysqldump
  563. \fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
  564. \fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
  565. .sp
  566. Write a debugging log\&. A typical
  567. \fIdebug_options\fR
  568. string is
  569. \'d:t:o,\fIfile_name\fR\'\&. The default value is
  570. \'d:t:o,/tmp/mysqldump\&.trace\'\&.
  571. .RE
  572. .sp
  573. .RS 4
  574. .ie n \{\
  575. \h'-04'\(bu\h'+03'\c
  576. .\}
  577. .el \{\
  578. .sp -1
  579. .IP \(bu 2.3
  580. .\}
  581. .\" mysqldump: debug-check option
  582. .\" debug-check option: mysqldump
  583. \fB\-\-debug\-check\fR
  584. .sp
  585. Print some debugging information when the program exits\&. This option was added in MySQL 5\&.1\&.21\&.
  586. .RE
  587. .sp
  588. .RS 4
  589. .ie n \{\
  590. \h'-04'\(bu\h'+03'\c
  591. .\}
  592. .el \{\
  593. .sp -1
  594. .IP \(bu 2.3
  595. .\}
  596. .\" mysqldump: debug-info option
  597. .\" debug-info option: mysqldump
  598. \fB\-\-debug\-info\fR
  599. .sp
  600. Print debugging information and memory and CPU usage statistics when the program exits\&. This option was added in MySQL 5\&.1\&.14\&.
  601. .RE
  602. .sp
  603. .RS 4
  604. .ie n \{\
  605. \h'-04'\(bu\h'+03'\c
  606. .\}
  607. .el \{\
  608. .sp -1
  609. .IP \(bu 2.3
  610. .\}
  611. .\" mysqldump: default-character-set option
  612. .\" default-character-set option: mysqldump
  613. \fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR
  614. .sp
  615. Use
  616. \fIcharset_name\fR
  617. as the default character set\&. See
  618. Section\ \&9.5, \(lqCharacter Set Configuration\(rq\&. If no character set is specified,
  619. \fBmysqldump\fR
  620. uses
  621. utf8, and earlier versions use
  622. latin1\&.
  623. .sp
  624. Prior to MySQL 5\&.1\&.38, this option has no effect for output data files produced by using the
  625. \fB\-\-tab\fR
  626. option\&. See the description for that option\&.
  627. .RE
  628. .sp
  629. .RS 4
  630. .ie n \{\
  631. \h'-04'\(bu\h'+03'\c
  632. .\}
  633. .el \{\
  634. .sp -1
  635. .IP \(bu 2.3
  636. .\}
  637. .\" mysqldump: delayed-insert option
  638. .\" delayed-insert option: mysqldump
  639. \fB\-\-delayed\-insert\fR
  640. .sp
  641. Write
  642. INSERT DELAYED
  643. statements rather than
  644. INSERT
  645. statements\&.
  646. .RE
  647. .sp
  648. .RS 4
  649. .ie n \{\
  650. \h'-04'\(bu\h'+03'\c
  651. .\}
  652. .el \{\
  653. .sp -1
  654. .IP \(bu 2.3
  655. .\}
  656. .\" mysqldump: delete-master-logs option
  657. .\" delete-master-logs option: mysqldump
  658. \fB\-\-delete\-master\-logs\fR
  659. .sp
  660. On a master replication server, delete the binary logs by sending a
  661. PURGE BINARY LOGS
  662. statement to the server after performing the dump operation\&. This option automatically enables
  663. \fB\-\-master\-data\fR\&.
  664. .RE
  665. .sp
  666. .RS 4
  667. .ie n \{\
  668. \h'-04'\(bu\h'+03'\c
  669. .\}
  670. .el \{\
  671. .sp -1
  672. .IP \(bu 2.3
  673. .\}
  674. .\" mysqldump: disable-keys option
  675. .\" disable-keys option: mysqldump
  676. \fB\-\-disable\-keys\fR,
  677. \fB\-K\fR
  678. .sp
  679. For each table, surround the
  680. INSERT
  681. statements with
  682. /*!40000 ALTER TABLE \fItbl_name\fR DISABLE KEYS */;
  683. and
  684. /*!40000 ALTER TABLE \fItbl_name\fR ENABLE KEYS */;
  685. statements\&. This makes loading the dump file faster because the indexes are created after all rows are inserted\&. This option is effective only for nonunique indexes of
  686. MyISAM
  687. tables\&.
  688. .RE
  689. .sp
  690. .RS 4
  691. .ie n \{\
  692. \h'-04'\(bu\h'+03'\c
  693. .\}
  694. .el \{\
  695. .sp -1
  696. .IP \(bu 2.3
  697. .\}
  698. .\" mysqldump: dump-date option
  699. .\" dump-date option: mysqldump
  700. \fB\-\-dump\-date\fR
  701. .sp
  702. If the
  703. \fB\-\-comments\fR
  704. option is given,
  705. \fBmysqldump\fR
  706. produces a comment at the end of the dump of the following form:
  707. .sp
  708. .if n \{\
  709. .RS 4
  710. .\}
  711. .nf
  712. \-\- Dump completed on \fIDATE\fR
  713. .fi
  714. .if n \{\
  715. .RE
  716. .\}
  717. .sp
  718. However, the date causes dump files taken at different times to appear to be different, even if the data are otherwise identical\&.
  719. \fB\-\-dump\-date\fR
  720. and
  721. \fB\-\-skip\-dump\-date\fR
  722. control whether the date is added to the comment\&. The default is
  723. \fB\-\-dump\-date\fR
  724. (include the date in the comment)\&.
  725. \fB\-\-skip\-dump\-date\fR
  726. suppresses date printing\&. This option was added in MySQL 5\&.1\&.23\&.
  727. .RE
  728. .sp
  729. .RS 4
  730. .ie n \{\
  731. \h'-04'\(bu\h'+03'\c
  732. .\}
  733. .el \{\
  734. .sp -1
  735. .IP \(bu 2.3
  736. .\}
  737. .\" mysqldump: events option
  738. .\" events option: mysqldump
  739. \fB\-\-events\fR,
  740. \fB\-E\fR
  741. .sp
  742. Include Event Scheduler events for the dumped databases in the output\&. This option was added in MySQL 5\&.1\&.8\&.
  743. .RE
  744. .sp
  745. .RS 4
  746. .ie n \{\
  747. \h'-04'\(bu\h'+03'\c
  748. .\}
  749. .el \{\
  750. .sp -1
  751. .IP \(bu 2.3
  752. .\}
  753. .\" mysqldump: extended-insert option
  754. .\" extended-insert option: mysqldump
  755. \fB\-\-extended\-insert\fR,
  756. \fB\-e\fR
  757. .sp
  758. Use multiple\-row
  759. INSERT
  760. syntax that include several
  761. VALUES
  762. lists\&. This results in a smaller dump file and speeds up inserts when the file is reloaded\&.
  763. .RE
  764. .sp
  765. .RS 4
  766. .ie n \{\
  767. \h'-04'\(bu\h'+03'\c
  768. .\}
  769. .el \{\
  770. .sp -1
  771. .IP \(bu 2.3
  772. .\}
  773. .\" mysqldump: fields-terminated-by option
  774. .\" fields-terminated-by option: mysqldump
  775. \fB\-\-fields\-terminated\-by=\&.\&.\&.\fR,
  776. .\" mysqldump: fields-enclosed-by option
  777. .\" fields-enclosed-by option: mysqldump
  778. \fB\-\-fields\-enclosed\-by=\&.\&.\&.\fR,
  779. .\" mysqldump: fields-optionally-enclosed-by option
  780. .\" fields-optionally-enclosed-by option: mysqldump
  781. \fB\-\-fields\-optionally\-enclosed\-by=\&.\&.\&.\fR,
  782. .\" mysqldump: fields-escaped-by option
  783. .\" fields-escaped-by option: mysqldump
  784. \fB\-\-fields\-escaped\-by=\&.\&.\&.\fR
  785. .sp
  786. These options are used with the
  787. \fB\-\-tab\fR
  788. option and have the same meaning as the corresponding
  789. FIELDS
  790. clauses for
  791. LOAD DATA INFILE\&. See
  792. Section\ \&12.2.6, \(lqLOAD DATA INFILE Syntax\(rq\&.
  793. .RE
  794. .sp
  795. .RS 4
  796. .ie n \{\
  797. \h'-04'\(bu\h'+03'\c
  798. .\}
  799. .el \{\
  800. .sp -1
  801. .IP \(bu 2.3
  802. .\}
  803. .\" mysqldump: first-slave option
  804. .\" first-slave option: mysqldump
  805. \fB\-\-first\-slave\fR
  806. .sp
  807. Deprecated\&. Use
  808. \fB\-\-lock\-all\-tables\fR
  809. instead\&.
  810. \fB\-\-first\-slave\fR
  811. is removed in MySQL 5\&.5\&.
  812. .RE
  813. .sp
  814. .RS 4
  815. .ie n \{\
  816. \h'-04'\(bu\h'+03'\c
  817. .\}
  818. .el \{\
  819. .sp -1
  820. .IP \(bu 2.3
  821. .\}
  822. .\" mysqldump: flush-logs option
  823. .\" flush-logs option: mysqldump
  824. \fB\-\-flush\-logs\fR,
  825. \fB\-F\fR
  826. .sp
  827. Flush the MySQL server log files before starting the dump\&. This option requires the
  828. RELOAD
  829. privilege\&. If you use this option in combination with the
  830. \fB\-\-all\-databases\fR
  831. option, the logs are flushed
  832. \fIfor each database dumped\fR\&. The exception is when using
  833. \fB\-\-lock\-all\-tables\fR
  834. or
  835. \fB\-\-master\-data\fR: In this case, the logs are flushed only once, corresponding to the moment that all tables are locked\&. If you want your dump and the log flush to happen at exactly the same moment, you should use
  836. \fB\-\-flush\-logs\fR
  837. together with either
  838. \fB\-\-lock\-all\-tables\fR
  839. or
  840. \fB\-\-master\-data\fR\&.
  841. .RE
  842. .sp
  843. .RS 4
  844. .ie n \{\
  845. \h'-04'\(bu\h'+03'\c
  846. .\}
  847. .el \{\
  848. .sp -1
  849. .IP \(bu 2.3
  850. .\}
  851. .\" mysqldump: flush-privileges option
  852. .\" flush-privileges option: mysqldump
  853. \fB\-\-flush\-privileges\fR
  854. .sp
  855. Send a
  856. FLUSH PRIVILEGES
  857. statement to the server after dumping the
  858. mysql
  859. database\&. This option should be used any time the dump contains the
  860. mysql
  861. database and any other database that depends on the data in the
  862. mysql
  863. database for proper restoration\&. This option was added in MySQL 5\&.1\&.12\&.
  864. .RE
  865. .sp
  866. .RS 4
  867. .ie n \{\
  868. \h'-04'\(bu\h'+03'\c
  869. .\}
  870. .el \{\
  871. .sp -1
  872. .IP \(bu 2.3
  873. .\}
  874. .\" mysqldump: force option
  875. .\" force option: mysqldump
  876. \fB\-\-force\fR,
  877. \fB\-f\fR
  878. .sp
  879. Continue even if an SQL error occurs during a table dump\&.
  880. .sp
  881. One use for this option is to cause
  882. \fBmysqldump\fR
  883. to continue executing even when it encounters a view that has become invalid because the definition refers to a table that has been dropped\&. Without
  884. \fB\-\-force\fR,
  885. \fBmysqldump\fR
  886. exits with an error message\&. With
  887. \fB\-\-force\fR,
  888. \fBmysqldump\fR
  889. prints the error message, but it also writes an SQL comment containing the view definition to the dump output and continues executing\&.
  890. .RE
  891. .sp
  892. .RS 4
  893. .ie n \{\
  894. \h'-04'\(bu\h'+03'\c
  895. .\}
  896. .el \{\
  897. .sp -1
  898. .IP \(bu 2.3
  899. .\}
  900. .\" mysqldump: host option
  901. .\" host option: mysqldump
  902. \fB\-\-host=\fR\fB\fIhost_name\fR\fR,
  903. \fB\-h \fR\fB\fIhost_name\fR\fR
  904. .sp
  905. Dump data from the MySQL server on the given host\&. The default host is
  906. localhost\&.
  907. .RE
  908. .sp
  909. .RS 4
  910. .ie n \{\
  911. \h'-04'\(bu\h'+03'\c
  912. .\}
  913. .el \{\
  914. .sp -1
  915. .IP \(bu 2.3
  916. .\}
  917. .\" mysqldump: hex-blob option
  918. .\" hex-blob option: mysqldump
  919. \fB\-\-hex\-blob\fR
  920. .sp
  921. Dump binary columns using hexadecimal notation (for example,
  922. \'abc\'
  923. becomes
  924. 0x616263)\&. The affected data types are
  925. BINARY,
  926. VARBINARY, the
  927. BLOB
  928. types, and
  929. BIT\&.
  930. .RE
  931. .sp
  932. .RS 4
  933. .ie n \{\
  934. \h'-04'\(bu\h'+03'\c
  935. .\}
  936. .el \{\
  937. .sp -1
  938. .IP \(bu 2.3
  939. .\}
  940. .\" mysqldump: ignore-table option
  941. .\" ignore-table option: mysqldump
  942. \fB\-\-ignore\-table=\fR\fB\fIdb_name\&.tbl_name\fR\fR
  943. .sp
  944. Do not dump the given table, which must be specified using both the database and table names\&. To ignore multiple tables, use this option multiple times\&. This option also can be used to ignore views\&.
  945. .RE
  946. .sp
  947. .RS 4
  948. .ie n \{\
  949. \h'-04'\(bu\h'+03'\c
  950. .\}
  951. .el \{\
  952. .sp -1
  953. .IP \(bu 2.3
  954. .\}
  955. .\" mysqldump: insert-ignore option
  956. .\" insert-ignore option: mysqldump
  957. \fB\-\-insert\-ignore\fR
  958. .sp
  959. Write
  960. INSERT IGNORE
  961. statements rather than
  962. INSERT
  963. statements\&.
  964. .RE
  965. .sp
  966. .RS 4
  967. .ie n \{\
  968. \h'-04'\(bu\h'+03'\c
  969. .\}
  970. .el \{\
  971. .sp -1
  972. .IP \(bu 2.3
  973. .\}
  974. .\" mysqldump: lines-terminated-by option
  975. .\" lines-terminated-by option: mysqldump
  976. \fB\-\-lines\-terminated\-by=\&.\&.\&.\fR
  977. .sp
  978. This option is used with the
  979. \fB\-\-tab\fR
  980. option and has the same meaning as the corresponding
  981. LINES
  982. clause for
  983. LOAD DATA INFILE\&. See
  984. Section\ \&12.2.6, \(lqLOAD DATA INFILE Syntax\(rq\&.
  985. .RE
  986. .sp
  987. .RS 4
  988. .ie n \{\
  989. \h'-04'\(bu\h'+03'\c
  990. .\}
  991. .el \{\
  992. .sp -1
  993. .IP \(bu 2.3
  994. .\}
  995. .\" mysqldump: lock-all-tables option
  996. .\" lock-all-tables option: mysqldump
  997. \fB\-\-lock\-all\-tables\fR,
  998. \fB\-x\fR
  999. .sp
  1000. Lock all tables across all databases\&. This is achieved by acquiring a global read lock for the duration of the whole dump\&. This option automatically turns off
  1001. \fB\-\-single\-transaction\fR
  1002. and
  1003. \fB\-\-lock\-tables\fR\&.
  1004. .RE
  1005. .sp
  1006. .RS 4
  1007. .ie n \{\
  1008. \h'-04'\(bu\h'+03'\c
  1009. .\}
  1010. .el \{\
  1011. .sp -1
  1012. .IP \(bu 2.3
  1013. .\}
  1014. .\" mysqldump: lock-tables option
  1015. .\" lock-tables option: mysqldump
  1016. \fB\-\-lock\-tables\fR,
  1017. \fB\-l\fR
  1018. .sp
  1019. For each dumped database, lock all tables to be dumped before dumping them\&. The tables are locked with
  1020. READ LOCAL
  1021. to allow concurrent inserts in the case of
  1022. MyISAM
  1023. tables\&. For transactional tables such as
  1024. InnoDB,
  1025. \fB\-\-single\-transaction\fR
  1026. is a much better option than
  1027. \fB\-\-lock\-tables\fR
  1028. because it does not need to lock the tables at all\&.
  1029. .sp
  1030. Because
  1031. \fB\-\-lock\-tables\fR
  1032. locks tables for each database separately, this option does not guarantee that the tables in the dump file are logically consistent between databases\&. Tables in different databases may be dumped in completely different states\&.
  1033. .RE
  1034. .sp
  1035. .RS 4
  1036. .ie n \{\
  1037. \h'-04'\(bu\h'+03'\c
  1038. .\}
  1039. .el \{\
  1040. .sp -1
  1041. .IP \(bu 2.3
  1042. .\}
  1043. .\" mysqldump: log-error option
  1044. .\" log-error option: mysqldump
  1045. \fB\-\-log\-error=\fR\fB\fIfile_name\fR\fR
  1046. .sp
  1047. Log warnings and errors by appending them to the named file\&. The default is to do no logging\&. This option was added in MySQL 5\&.1\&.18\&.
  1048. .RE
  1049. .sp
  1050. .RS 4
  1051. .ie n \{\
  1052. \h'-04'\(bu\h'+03'\c
  1053. .\}
  1054. .el \{\
  1055. .sp -1
  1056. .IP \(bu 2.3
  1057. .\}
  1058. .\" mysqldump: master-data option
  1059. .\" master-data option: mysqldump
  1060. \fB\-\-master\-data[=\fR\fB\fIvalue\fR\fR\fB]\fR
  1061. .sp
  1062. Use this option to dump a master replication server to produce a dump file that can be used to set up another server as a slave of the master\&. It causes the dump output to include a
  1063. CHANGE MASTER TO
  1064. statement that indicates the binary log coordinates (file name and position) of the dumped server\&. These are the master server coordinates from which the slave should start replicating after you load the dump file into the slave\&.
  1065. .sp
  1066. If the option value is 2, the
  1067. CHANGE MASTER TO
  1068. statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded\&. If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded\&. If no option value is specified, the default value is 1\&.
  1069. .sp
  1070. This option requires the
  1071. RELOAD
  1072. privilege and the binary log must be enabled\&.
  1073. .sp
  1074. The
  1075. \fB\-\-master\-data\fR
  1076. option automatically turns off
  1077. \fB\-\-lock\-tables\fR\&. It also turns on
  1078. \fB\-\-lock\-all\-tables\fR, unless
  1079. \fB\-\-single\-transaction\fR
  1080. also is specified, in which case, a global read lock is acquired only for a short time at the beginning of the dump (see the description for
  1081. \fB\-\-single\-transaction\fR)\&. In all cases, any action on logs happens at the exact moment of the dump\&.
  1082. .sp
  1083. It is also possible to set up a slave by dumping an existing slave of the master\&. To do this, use the following procedure on the existing slave:
  1084. .sp
  1085. .RS 4
  1086. .ie n \{\
  1087. \h'-04' 1.\h'+01'\c
  1088. .\}
  1089. .el \{\
  1090. .sp -1
  1091. .IP " 1." 4.2
  1092. .\}
  1093. Stop the slave\'s SQL thread and get its current status:
  1094. .sp
  1095. .if n \{\
  1096. .RS 4
  1097. .\}
  1098. .nf
  1099. mysql> \fBSTOP SLAVE SQL_THREAD;\fR
  1100. mysql> \fBSHOW SLAVE STATUS;\fR
  1101. .fi
  1102. .if n \{\
  1103. .RE
  1104. .\}
  1105. .RE
  1106. .sp
  1107. .RS 4
  1108. .ie n \{\
  1109. \h'-04' 2.\h'+01'\c
  1110. .\}
  1111. .el \{\
  1112. .sp -1
  1113. .IP " 2." 4.2
  1114. .\}
  1115. From the output of the
  1116. SHOW SLAVE STATUS
  1117. statement, the binary log coordinates of the master server from which the new slave should start replicating are the values of the
  1118. Relay_Master_Log_File
  1119. and
  1120. Exec_Master_Log_Pos
  1121. fields\&. Denote those values as
  1122. \fIfile_name\fR
  1123. and
  1124. \fIfile_pos\fR\&.
  1125. .RE
  1126. .sp
  1127. .RS 4
  1128. .ie n \{\
  1129. \h'-04' 3.\h'+01'\c
  1130. .\}
  1131. .el \{\
  1132. .sp -1
  1133. .IP " 3." 4.2
  1134. .\}
  1135. Dump the slave server:
  1136. .sp
  1137. .if n \{\
  1138. .RS 4
  1139. .\}
  1140. .nf
  1141. shell> \fBmysqldump \-\-master\-data=2 \-\-all\-databases > dumpfile\fR
  1142. .fi
  1143. .if n \{\
  1144. .RE
  1145. .\}
  1146. .RE
  1147. .sp
  1148. .RS 4
  1149. .ie n \{\
  1150. \h'-04' 4.\h'+01'\c
  1151. .\}
  1152. .el \{\
  1153. .sp -1
  1154. .IP " 4." 4.2
  1155. .\}
  1156. Restart the slave:
  1157. .sp
  1158. .if n \{\
  1159. .RS 4
  1160. .\}
  1161. .nf
  1162. mysql> \fBSTART SLAVE;\fR
  1163. .fi
  1164. .if n \{\
  1165. .RE
  1166. .\}
  1167. .RE
  1168. .sp
  1169. .RS 4
  1170. .ie n \{\
  1171. \h'-04' 5.\h'+01'\c
  1172. .\}
  1173. .el \{\
  1174. .sp -1
  1175. .IP " 5." 4.2
  1176. .\}
  1177. On the new slave, load the dump file:
  1178. .sp
  1179. .if n \{\
  1180. .RS 4
  1181. .\}
  1182. .nf
  1183. shell> \fBmysql < dumpfile\fR
  1184. .fi
  1185. .if n \{\
  1186. .RE
  1187. .\}
  1188. .RE
  1189. .sp
  1190. .RS 4
  1191. .ie n \{\
  1192. \h'-04' 6.\h'+01'\c
  1193. .\}
  1194. .el \{\
  1195. .sp -1
  1196. .IP " 6." 4.2
  1197. .\}
  1198. On the new slave, set the replication coordinates to those of the master server obtained earlier:
  1199. .sp
  1200. .if n \{\
  1201. .RS 4
  1202. .\}
  1203. .nf
  1204. mysql> \fBCHANGE MASTER TO\fR
  1205. \-> \fBMASTER_LOG_FILE = \'\fR\fB\fIfile_name\fR\fR\fB\', MASTER_LOG_POS = \fR\fB\fIfile_pos\fR\fR\fB;\fR
  1206. .fi
  1207. .if n \{\
  1208. .RE
  1209. .\}
  1210. .sp
  1211. The
  1212. CHANGE MASTER TO
  1213. statement might also need other parameters, such as
  1214. MASTER_HOST
  1215. to point the slave to the correct master server host\&. Add any such parameters as necessary\&.
  1216. .RE
  1217. .RE
  1218. .sp
  1219. .RS 4
  1220. .ie n \{\
  1221. \h'-04'\(bu\h'+03'\c
  1222. .\}
  1223. .el \{\
  1224. .sp -1
  1225. .IP \(bu 2.3
  1226. .\}
  1227. .\" mysqldump: no-autocommit option
  1228. .\" no-autocommit option: mysqldump
  1229. \fB\-\-no\-autocommit\fR
  1230. .sp
  1231. Enclose the
  1232. INSERT
  1233. statements for each dumped table within
  1234. SET autocommit = 0
  1235. and
  1236. COMMIT
  1237. statements\&.
  1238. .RE
  1239. .sp
  1240. .RS 4
  1241. .ie n \{\
  1242. \h'-04'\(bu\h'+03'\c
  1243. .\}
  1244. .el \{\
  1245. .sp -1
  1246. .IP \(bu 2.3
  1247. .\}
  1248. .\" mysqldump: no-create-db option
  1249. .\" no-create-db option: mysqldump
  1250. \fB\-\-no\-create\-db\fR,
  1251. \fB\-n\fR
  1252. .sp
  1253. This option suppresses the
  1254. CREATE DATABASE
  1255. statements that are otherwise included in the output if the
  1256. \fB\-\-databases\fR
  1257. or
  1258. \fB\-\-all\-databases\fR
  1259. option is given\&.
  1260. .RE
  1261. .sp
  1262. .RS 4
  1263. .ie n \{\
  1264. \h'-04'\(bu\h'+03'\c
  1265. .\}
  1266. .el \{\
  1267. .sp -1
  1268. .IP \(bu 2.3
  1269. .\}
  1270. .\" mysqldump: no-create-info option
  1271. .\" no-create-info option: mysqldump
  1272. \fB\-\-no\-create\-info\fR,
  1273. \fB\-t\fR
  1274. .sp
  1275. Do not write
  1276. CREATE TABLE
  1277. statements that re\-create each dumped table\&.
  1278. .RE
  1279. .sp
  1280. .RS 4
  1281. .ie n \{\
  1282. \h'-04'\(bu\h'+03'\c
  1283. .\}
  1284. .el \{\
  1285. .sp -1
  1286. .IP \(bu 2.3
  1287. .\}
  1288. .\" mysqldump: no-data option
  1289. .\" no-data option: mysqldump
  1290. \fB\-\-no\-data\fR,
  1291. \fB\-d\fR
  1292. .sp
  1293. Do not write any table row information (that is, do not dump table contents)\&. This is useful if you want to dump only the
  1294. CREATE TABLE
  1295. statement for the table (for example, to create an empty copy of the table by loading the dump file)\&.
  1296. .RE
  1297. .sp
  1298. .RS 4
  1299. .ie n \{\
  1300. \h'-04'\(bu\h'+03'\c
  1301. .\}
  1302. .el \{\
  1303. .sp -1
  1304. .IP \(bu 2.3
  1305. .\}
  1306. .\" mysqldump: no-set-names option
  1307. .\" no-set-names option: mysqldump
  1308. \fB\-\-no\-set\-names\fR,
  1309. \fB\-N\fR
  1310. .sp
  1311. This has the same effect as
  1312. \fB\-\-skip\-set\-charset\fR\&.
  1313. .RE
  1314. .sp
  1315. .RS 4
  1316. .ie n \{\
  1317. \h'-04'\(bu\h'+03'\c
  1318. .\}
  1319. .el \{\
  1320. .sp -1
  1321. .IP \(bu 2.3
  1322. .\}
  1323. .\" mysqldump: opt option
  1324. .\" opt option: mysqldump
  1325. \fB\-\-opt\fR
  1326. .sp
  1327. This option is shorthand\&. It is the same as specifying
  1328. \fB\-\-add\-drop\-table\fR
  1329. \fB\-\-add\-locks\fR
  1330. \fB\-\-create\-options\fR
  1331. \fB\-\-disable\-keys\fR
  1332. \fB\-\-extended\-insert\fR
  1333. \fB\-\-lock\-tables\fR
  1334. \fB\-\-quick\fR
  1335. \fB\-\-set\-charset\fR\&. It should give you a fast dump operation and produce a dump file that can be reloaded into a MySQL server quickly\&.
  1336. .sp
  1337. \fIThe \fR\fI\fB\-\-opt\fR\fR\fI option is enabled by default\&. Use \fR\fI\fB\-\-skip\-opt\fR\fR\fI to disable it\&.\fR
  1338. See the discussion at the beginning of this section for information about selectively enabling or disabling a subset of the options affected by
  1339. \fB\-\-opt\fR\&.
  1340. .RE
  1341. .sp
  1342. .RS 4
  1343. .ie n \{\
  1344. \h'-04'\(bu\h'+03'\c
  1345. .\}
  1346. .el \{\
  1347. .sp -1
  1348. .IP \(bu 2.3
  1349. .\}
  1350. .\" mysqldump: order-by-primary option
  1351. .\" order-by-primary option: mysqldump
  1352. \fB\-\-order\-by\-primary\fR
  1353. .sp
  1354. Dump each table\'s rows sorted by its primary key, or by its first unique index, if such an index exists\&. This is useful when dumping a
  1355. MyISAM
  1356. table to be loaded into an
  1357. InnoDB
  1358. table, but will make the dump operation take considerably longer\&.
  1359. .RE
  1360. .sp
  1361. .RS 4
  1362. .ie n \{\
  1363. \h'-04'\(bu\h'+03'\c
  1364. .\}
  1365. .el \{\
  1366. .sp -1
  1367. .IP \(bu 2.3
  1368. .\}
  1369. .\" mysqldump: password option
  1370. .\" password option: mysqldump
  1371. \fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
  1372. \fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
  1373. .sp
  1374. The password to use when connecting to the server\&. If you use the short option form (\fB\-p\fR), you
  1375. \fIcannot\fR
  1376. have a space between the option and the password\&. If you omit the
  1377. \fIpassword\fR
  1378. value following the
  1379. \fB\-\-password\fR
  1380. or
  1381. \fB\-p\fR
  1382. option on the command line,
  1383. \fBmysqldump\fR
  1384. prompts for one\&.
  1385. .sp
  1386. Specifying a password on the command line should be considered insecure\&. See
  1387. Section\ \&5.3.2.2, \(lqEnd-User Guidelines for Password Security\(rq\&. You can use an option file to avoid giving the password on the command line\&.
  1388. .RE
  1389. .sp
  1390. .RS 4
  1391. .ie n \{\
  1392. \h'-04'\(bu\h'+03'\c
  1393. .\}
  1394. .el \{\
  1395. .sp -1
  1396. .IP \(bu 2.3
  1397. .\}
  1398. .\" mysqldump: pipe option
  1399. .\" pipe option: mysqldump
  1400. \fB\-\-pipe\fR,
  1401. \fB\-W\fR
  1402. .sp
  1403. On Windows, connect to the server via a named pipe\&. This option applies only if the server supports named\-pipe connections\&.
  1404. .RE
  1405. .sp
  1406. .RS 4
  1407. .ie n \{\
  1408. \h'-04'\(bu\h'+03'\c
  1409. .\}
  1410. .el \{\
  1411. .sp -1
  1412. .IP \(bu 2.3
  1413. .\}
  1414. .\" mysqldump: port option
  1415. .\" port option: mysqldump
  1416. \fB\-\-port=\fR\fB\fIport_num\fR\fR,
  1417. \fB\-P \fR\fB\fIport_num\fR\fR
  1418. .sp
  1419. The TCP/IP port number to use for the connection\&.
  1420. .RE
  1421. .sp
  1422. .RS 4
  1423. .ie n \{\
  1424. \h'-04'\(bu\h'+03'\c
  1425. .\}
  1426. .el \{\
  1427. .sp -1
  1428. .IP \(bu 2.3
  1429. .\}
  1430. .\" mysqldump: protocol option
  1431. .\" protocol option: mysqldump
  1432. \fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
  1433. .sp
  1434. The connection protocol to use for connecting to the server\&. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want\&. For details on the allowable values, see
  1435. Section\ \&4.2.2, \(lqConnecting to the MySQL Server\(rq\&.
  1436. .RE
  1437. .sp
  1438. .RS 4
  1439. .ie n \{\
  1440. \h'-04'\(bu\h'+03'\c
  1441. .\}
  1442. .el \{\
  1443. .sp -1
  1444. .IP \(bu 2.3
  1445. .\}
  1446. .\" mysqldump: quick option
  1447. .\" quick option: mysqldump
  1448. \fB\-\-quick\fR,
  1449. \fB\-q\fR
  1450. .sp
  1451. This option is useful for dumping large tables\&. It forces
  1452. \fBmysqldump\fR
  1453. to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out\&.
  1454. .RE
  1455. .sp
  1456. .RS 4
  1457. .ie n \{\
  1458. \h'-04'\(bu\h'+03'\c
  1459. .\}
  1460. .el \{\
  1461. .sp -1
  1462. .IP \(bu 2.3
  1463. .\}
  1464. .\" mysqldump: quote-names option
  1465. .\" quote-names option: mysqldump
  1466. \fB\-\-quote\-names\fR,
  1467. \fB\-Q\fR
  1468. .sp
  1469. Quote identifiers (such as database, table, and column names) within
  1470. \(lq`\(rq
  1471. characters\&. If the
  1472. ANSI_QUOTES
  1473. SQL mode is enabled, identifiers are quoted within
  1474. \(lq"\(rq
  1475. characters\&. This option is enabled by default\&. It can be disabled with
  1476. \fB\-\-skip\-quote\-names\fR, but this option should be given after any option such as
  1477. \fB\-\-compatible\fR
  1478. that may enable
  1479. \fB\-\-quote\-names\fR\&.
  1480. .RE
  1481. .sp
  1482. .RS 4
  1483. .ie n \{\
  1484. \h'-04'\(bu\h'+03'\c
  1485. .\}
  1486. .el \{\
  1487. .sp -1
  1488. .IP \(bu 2.3
  1489. .\}
  1490. .\" mysqldump: replace option
  1491. .\" replace option: mysqldump
  1492. \fB\-\-replace\fR
  1493. .sp
  1494. Write
  1495. REPLACE
  1496. statements rather than
  1497. INSERT
  1498. statements\&. This option was added in MySQL 5\&.1\&.3\&.
  1499. .RE
  1500. .sp
  1501. .RS 4
  1502. .ie n \{\
  1503. \h'-04'\(bu\h'+03'\c
  1504. .\}
  1505. .el \{\
  1506. .sp -1
  1507. .IP \(bu 2.3
  1508. .\}
  1509. .\" mysqldump: result-file option
  1510. .\" result-file option: mysqldump
  1511. \fB\-\-result\-file=\fR\fB\fIfile_name\fR\fR,
  1512. \fB\-r \fR\fB\fIfile_name\fR\fR
  1513. .sp
  1514. Direct output to a given file\&. This option should be used on Windows to prevent newline
  1515. \(lq\en\(rq
  1516. characters from being converted to
  1517. \(lq\er\en\(rq
  1518. carriage return/newline sequences\&. The result file is created and its previous contents overwritten, even if an error occurs while generating the dump\&.
  1519. .RE
  1520. .sp
  1521. .RS 4
  1522. .ie n \{\
  1523. \h'-04'\(bu\h'+03'\c
  1524. .\}
  1525. .el \{\
  1526. .sp -1
  1527. .IP \(bu 2.3
  1528. .\}
  1529. .\" mysqldump: routines option
  1530. .\" routines option: mysqldump
  1531. \fB\-\-routines\fR,
  1532. \fB\-R\fR
  1533. .sp
  1534. Included stored routines (procedures and functions) for the dumped databases in the output\&. Use of this option requires the
  1535. SELECT
  1536. privilege for the
  1537. mysql\&.proc
  1538. table\&. The output generated by using
  1539. \fB\-\-routines\fR
  1540. contains
  1541. CREATE PROCEDURE
  1542. and
  1543. CREATE FUNCTION
  1544. statements to re\-create the routines\&. However, these statements do not include attributes such as the routine creation and modification timestamps\&. This means that when the routines are reloaded, they will be created with the timestamps equal to the reload time\&.
  1545. .sp
  1546. If you require routines to be re\-created with their original timestamp attributes, do not use
  1547. \fB\-\-routines\fR\&. Instead, dump and reload the contents of the
  1548. mysql\&.proc
  1549. table directly, using a MySQL account that has appropriate privileges for the
  1550. mysql
  1551. database\&.
  1552. .sp
  1553. This option was added in MySQL 5\&.1\&.2\&. Before that, stored routines are not dumped\&. Routine
  1554. DEFINER
  1555. values are not dumped until MySQL 5\&.1\&.8\&. This means that before 5\&.1\&.8, when routines are reloaded, they will be created with the definer set to the reloading user\&. If you require routines to be re\-created with their original definer, dump and load the contents of the
  1556. mysql\&.proc
  1557. table directly as described earlier\&.
  1558. .RE
  1559. .sp
  1560. .RS 4
  1561. .ie n \{\
  1562. \h'-04'\(bu\h'+03'\c
  1563. .\}
  1564. .el \{\
  1565. .sp -1
  1566. .IP \(bu 2.3
  1567. .\}
  1568. .\" mysqldump: set-charset option
  1569. .\" set-charset option: mysqldump
  1570. \fB\-\-set\-charset\fR
  1571. .sp
  1572. Add
  1573. SET NAMES \fIdefault_character_set\fR
  1574. to the output\&. This option is enabled by default\&. To suppress the
  1575. SET NAMES
  1576. statement, use
  1577. \fB\-\-skip\-set\-charset\fR\&.
  1578. .RE
  1579. .sp
  1580. .RS 4
  1581. .ie n \{\
  1582. \h'-04'\(bu\h'+03'\c
  1583. .\}
  1584. .el \{\
  1585. .sp -1
  1586. .IP \(bu 2.3
  1587. .\}
  1588. .\" mysqldump: single-transaction option
  1589. .\" single-transaction option: mysqldump
  1590. \fB\-\-single\-transaction\fR
  1591. .sp
  1592. This option sends a
  1593. START TRANSACTION
  1594. SQL statement to the server before dumping data\&. It is useful only with transactional tables such as
  1595. InnoDB, because then it dumps the consistent state of the database at the time when
  1596. BEGIN
  1597. was issued without blocking any applications\&.
  1598. .sp
  1599. When using this option, you should keep in mind that only
  1600. InnoDB
  1601. tables are dumped in a consistent state\&. For example, any
  1602. MyISAM
  1603. or
  1604. MEMORY
  1605. tables dumped while using this option may still change state\&.
  1606. .sp
  1607. While a
  1608. \fB\-\-single\-transaction\fR
  1609. dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements:
  1610. ALTER TABLE,
  1611. CREATE TABLE,
  1612. DROP TABLE,
  1613. RENAME TABLE,
  1614. TRUNCATE TABLE\&. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the
  1615. SELECT
  1616. that is performed by
  1617. \fBmysqldump\fR
  1618. to retrieve the table contents to obtain incorrect contents or fail\&.
  1619. .sp
  1620. The
  1621. \fB\-\-single\-transaction\fR
  1622. option and the
  1623. \fB\-\-lock\-tables\fR
  1624. option are mutually exclusive because
  1625. LOCK TABLES
  1626. causes any pending transactions to be committed implicitly\&.
  1627. .sp
  1628. This option is not supported for MySQL Cluster tables; the results cannot be guaranteed to be consistent due to the fact that the
  1629. NDBCLUSTER
  1630. storage engine supports only the
  1631. READ_COMMITTED
  1632. transaction isolation level\&. You should always use
  1633. NDB
  1634. backup and restore instead\&.
  1635. .sp
  1636. To dump large tables, you should combine the
  1637. \fB\-\-single\-transaction\fR
  1638. option with
  1639. \fB\-\-quick\fR\&.
  1640. .RE
  1641. .sp
  1642. .RS 4
  1643. .ie n \{\
  1644. \h'-04'\(bu\h'+03'\c
  1645. .\}
  1646. .el \{\
  1647. .sp -1
  1648. .IP \(bu 2.3
  1649. .\}
  1650. .\" mysqldump: skip-comments option
  1651. .\" skip-comments option: mysqldump
  1652. \fB\-\-skip\-comments\fR
  1653. .sp
  1654. See the description for the
  1655. \fB\-\-comments\fR
  1656. option\&.
  1657. .RE
  1658. .sp
  1659. .RS 4
  1660. .ie n \{\
  1661. \h'-04'\(bu\h'+03'\c
  1662. .\}
  1663. .el \{\
  1664. .sp -1
  1665. .IP \(bu 2.3
  1666. .\}
  1667. .\" mysqldump: skip-opt option
  1668. .\" skip-opt option: mysqldump
  1669. \fB\-\-skip\-opt\fR
  1670. .sp
  1671. See the description for the
  1672. \fB\-\-opt\fR
  1673. option\&.
  1674. .RE
  1675. .sp
  1676. .RS 4
  1677. .ie n \{\
  1678. \h'-04'\(bu\h'+03'\c
  1679. .\}
  1680. .el \{\
  1681. .sp -1
  1682. .IP \(bu 2.3
  1683. .\}
  1684. .\" mysqldump: socket option
  1685. .\" socket option: mysqldump
  1686. \fB\-\-socket=\fR\fB\fIpath\fR\fR,
  1687. \fB\-S \fR\fB\fIpath\fR\fR
  1688. .sp
  1689. For connections to
  1690. localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use\&.
  1691. .RE
  1692. .sp
  1693. .RS 4
  1694. .ie n \{\
  1695. \h'-04'\(bu\h'+03'\c
  1696. .\}
  1697. .el \{\
  1698. .sp -1
  1699. .IP \(bu 2.3
  1700. .\}
  1701. .\" mysqldump: SSL options
  1702. .\" SSL options: mysqldump
  1703. \fB\-\-ssl*\fR
  1704. .sp
  1705. Options that begin with
  1706. \fB\-\-ssl\fR
  1707. specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates\&. See
  1708. Section\ \&5.5.6.3, \(lqSSL Command Options\(rq\&.
  1709. .RE
  1710. .sp
  1711. .RS 4
  1712. .ie n \{\
  1713. \h'-04'\(bu\h'+03'\c
  1714. .\}
  1715. .el \{\
  1716. .sp -1
  1717. .IP \(bu 2.3
  1718. .\}
  1719. .\" mysqldump: tab option
  1720. .\" tab option: mysqldump
  1721. \fB\-\-tab=\fR\fB\fIpath\fR\fR,
  1722. \fB\-T \fR\fB\fIpath\fR\fR
  1723. .sp
  1724. Produce tab\-separated text\-format data files\&. For each dumped table,
  1725. \fBmysqldump\fR
  1726. creates a
  1727. \fItbl_name\fR\&.sql
  1728. file that contains the
  1729. CREATE TABLE
  1730. statement that creates the table, and the server writes a
  1731. \fItbl_name\fR\&.txt
  1732. file that contains its data\&. The option value is the directory in which to write the files\&.
  1733. .if n \{\
  1734. .sp
  1735. .\}
  1736. .RS 4
  1737. .it 1 an-trap
  1738. .nr an-no-space-flag 1
  1739. .nr an-break-flag 1
  1740. .br
  1741. .ps +1
  1742. \fBNote\fR
  1743. .ps -1
  1744. .br
  1745. This option should be used only when
  1746. \fBmysqldump\fR
  1747. is run on the same machine as the
  1748. \fBmysqld\fR
  1749. server\&. You must have the
  1750. FILE
  1751. privilege, and the server must have permission to write files in the directory that you specify\&.
  1752. .sp .5v
  1753. .RE
  1754. By default, the
  1755. \&.txt
  1756. data files are formatted using tab characters between column values and a newline at the end of each line\&. The format can be specified explicitly using the
  1757. \fB\-\-fields\-\fR\fB\fIxxx\fR\fR
  1758. and
  1759. \fB\-\-lines\-terminated\-by\fR
  1760. options\&.
  1761. .sp
  1762. As of MySQL 5\&.1\&.38, column values are converted to the character set specified by the
  1763. \fB\-\-default\-character\-set\fR
  1764. option\&. Prior to 5\&.1\&.38 or if no such option is present, values are dumped using the
  1765. binary
  1766. character set\&. In effect, there is no character set conversion\&. If a table contains columns in several character sets, the output data file will as well and you may not be able to reload the file correctly\&.
  1767. .RE
  1768. .sp
  1769. .RS 4
  1770. .ie n \{\
  1771. \h'-04'\(bu\h'+03'\c
  1772. .\}
  1773. .el \{\
  1774. .sp -1
  1775. .IP \(bu 2.3
  1776. .\}
  1777. .\" mysqldump: tables option
  1778. .\" tables option: mysqldump
  1779. \fB\-\-tables\fR
  1780. .sp
  1781. Override the
  1782. \fB\-\-databases\fR
  1783. or
  1784. \fB\-B\fR
  1785. option\&.
  1786. \fBmysqldump\fR
  1787. regards all name arguments following the option as table names\&.
  1788. .RE
  1789. .sp
  1790. .RS 4
  1791. .ie n \{\
  1792. \h'-04'\(bu\h'+03'\c
  1793. .\}
  1794. .el \{\
  1795. .sp -1
  1796. .IP \(bu 2.3
  1797. .\}
  1798. .\" mysqldump: triggers option
  1799. .\" triggers option: mysqldump
  1800. \fB\-\-triggers\fR
  1801. .sp
  1802. Include triggers for each dumped table in the output\&. This option is enabled by default; disable it with
  1803. \fB\-\-skip\-triggers\fR\&.
  1804. .RE
  1805. .sp
  1806. .RS 4
  1807. .ie n \{\
  1808. \h'-04'\(bu\h'+03'\c
  1809. .\}
  1810. .el \{\
  1811. .sp -1
  1812. .IP \(bu 2.3
  1813. .\}
  1814. .\" mysqldump: tz-utc option
  1815. .\" tz-utc option: mysqldump
  1816. \fB\-\-tz\-utc\fR
  1817. .sp
  1818. This option enables
  1819. TIMESTAMP
  1820. columns to be dumped and reloaded between servers in different time zones\&.
  1821. \fBmysqldump\fR
  1822. sets its connection time zone to UTC and adds
  1823. SET TIME_ZONE=\'+00:00\'
  1824. to the dump file\&. Without this option,
  1825. TIMESTAMP
  1826. columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones\&.
  1827. \fB\-\-tz\-utc\fR
  1828. also protects against changes due to daylight saving time\&.
  1829. \fB\-\-tz\-utc\fR
  1830. is enabled by default\&. To disable it, use
  1831. \fB\-\-skip\-tz\-utc\fR\&. This option was added in MySQL 5\&.1\&.2\&.
  1832. .RE
  1833. .sp
  1834. .RS 4
  1835. .ie n \{\
  1836. \h'-04'\(bu\h'+03'\c
  1837. .\}
  1838. .el \{\
  1839. .sp -1
  1840. .IP \(bu 2.3
  1841. .\}
  1842. .\" mysqldump: user option
  1843. .\" user option: mysqldump
  1844. \fB\-\-user=\fR\fB\fIuser_name\fR\fR,
  1845. \fB\-u \fR\fB\fIuser_name\fR\fR
  1846. .sp
  1847. The MySQL user name to use when connecting to the server\&.
  1848. .RE
  1849. .sp
  1850. .RS 4
  1851. .ie n \{\
  1852. \h'-04'\(bu\h'+03'\c
  1853. .\}
  1854. .el \{\
  1855. .sp -1
  1856. .IP \(bu 2.3
  1857. .\}
  1858. .\" mysqldump: verbose option
  1859. .\" verbose option: mysqldump
  1860. \fB\-\-verbose\fR,
  1861. \fB\-v\fR
  1862. .sp
  1863. Verbose mode\&. Print more information about what the program does\&.
  1864. .RE
  1865. .sp
  1866. .RS 4
  1867. .ie n \{\
  1868. \h'-04'\(bu\h'+03'\c
  1869. .\}
  1870. .el \{\
  1871. .sp -1
  1872. .IP \(bu 2.3
  1873. .\}
  1874. .\" mysqldump: version option
  1875. .\" version option: mysqldump
  1876. \fB\-\-version\fR,
  1877. \fB\-V\fR
  1878. .sp
  1879. Display version information and exit\&.
  1880. .RE
  1881. .sp
  1882. .RS 4
  1883. .ie n \{\
  1884. \h'-04'\(bu\h'+03'\c
  1885. .\}
  1886. .el \{\
  1887. .sp -1
  1888. .IP \(bu 2.3
  1889. .\}
  1890. .\" mysqldump: where option
  1891. .\" where option: mysqldump
  1892. \fB\-\-where=\'\fR\fB\fIwhere_condition\fR\fR\fB\'\fR,
  1893. \fB\-w \'\fR\fB\fIwhere_condition\fR\fR\fB\'\fR
  1894. .sp
  1895. Dump only rows selected by the given
  1896. WHERE
  1897. condition\&. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter\&.
  1898. .sp
  1899. Examples:
  1900. .sp
  1901. .if n \{\
  1902. .RS 4
  1903. .\}
  1904. .nf
  1905. \-\-where="user=\'jimf\'"
  1906. \-w"userid>1"
  1907. \-w"userid<1"
  1908. .fi
  1909. .if n \{\
  1910. .RE
  1911. .\}
  1912. .RE
  1913. .sp
  1914. .RS 4
  1915. .ie n \{\
  1916. \h'-04'\(bu\h'+03'\c
  1917. .\}
  1918. .el \{\
  1919. .sp -1
  1920. .IP \(bu 2.3
  1921. .\}
  1922. .\" mysqldump: xml option
  1923. .\" xml option: mysqldump
  1924. \fB\-\-xml\fR,
  1925. \fB\-X\fR
  1926. .sp
  1927. Write dump output as well\-formed XML\&.
  1928. .sp
  1929. \fBNULL\fR\fB, \fR\fB\'NULL\'\fR\fB, and Empty Values\fR: For a column named
  1930. \fIcolumn_name\fR, the
  1931. NULL
  1932. value, an empty string, and the string value
  1933. \'NULL\'
  1934. are distinguished from one another in the output generated by this option as follows\&.
  1935. .TS
  1936. allbox tab(:);
  1937. l l
  1938. l l
  1939. l l
  1940. l l.
  1941. T{
  1942. \fBValue\fR:
  1943. T}:T{
  1944. \fBXML Representation\fR:
  1945. T}
  1946. T{
  1947. NULL (\fIunknown value\fR)
  1948. T}:T{
  1949. <field name="\fIcolumn_name\fR" xsi:nil="true" />
  1950. T}
  1951. T{
  1952. \'\' (\fIempty string\fR)
  1953. T}:T{
  1954. <field name="\fIcolumn_name\fR"></field>
  1955. T}
  1956. T{
  1957. \'NULL\' (\fIstring value\fR)
  1958. T}:T{
  1959. <field name="\fIcolumn_name\fR">NULL</field>
  1960. T}
  1961. .TE
  1962. .sp 1
  1963. Beginning with MySQL 5\&.1\&.12, the output from the
  1964. \fBmysql\fR
  1965. client when run using the
  1966. \fB\-\-xml\fR
  1967. option also follows the preceding rules\&. (See
  1968. the section called \(lqMYSQL OPTIONS\(rq\&.)
  1969. .sp
  1970. Beginning with MySQL 5\&.1\&.18, XML output from
  1971. \fBmysqldump\fR
  1972. includes the XML namespace, as shown here:
  1973. .sp
  1974. .if n \{\
  1975. .RS 4
  1976. .\}
  1977. .nf
  1978. shell> \fBmysqldump \-\-xml \-u root world City\fR
  1979. <?xml version="1\&.0"?>
  1980. <mysqldump xmlns:xsi="http://www\&.w3\&.org/2001/XMLSchema\-instance">
  1981. <database name="world">
  1982. <table_structure name="City">
  1983. <field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
  1984. <field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
  1985. <field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
  1986. <field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
  1987. <field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
  1988. <key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID"
  1989. Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" />
  1990. <options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079"
  1991. Avg_row_length="67" Data_length="273293" Max_data_length="18858823439613951"
  1992. Index_length="43008" Data_free="0" Auto_increment="4080"
  1993. Create_time="2007\-03\-31 01:47:01" Update_time="2007\-03\-31 01:47:02"
  1994. Collation="latin1_swedish_ci" Create_options="" Comment="" />
  1995. </table_structure>
  1996. <table_data name="City">
  1997. <row>
  1998. <field name="ID">1</field>
  1999. <field name="Name">Kabul</field>
  2000. <field name="CountryCode">AFG</field>
  2001. <field name="District">Kabol</field>
  2002. <field name="Population">1780000</field>
  2003. </row>
  2004. \fI\&.\&.\&.\fR
  2005. <row>
  2006. <field name="ID">4079</field>
  2007. <field name="Name">Rafah</field>
  2008. <field name="CountryCode">PSE</field>
  2009. <field name="District">Rafah</field>
  2010. <field name="Population">92020</field>
  2011. </row>
  2012. </table_data>
  2013. </database>
  2014. </mysqldump>
  2015. .fi
  2016. .if n \{\
  2017. .RE
  2018. .\}
  2019. .sp
  2020. .RE
  2021. .PP
  2022. You can also set the following variables by using
  2023. \fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR
  2024. syntax:
  2025. .sp
  2026. .RS 4
  2027. .ie n \{\
  2028. \h'-04'\(bu\h'+03'\c
  2029. .\}
  2030. .el \{\
  2031. .sp -1
  2032. .IP \(bu 2.3
  2033. .\}
  2034. max_allowed_packet
  2035. .sp
  2036. The maximum size of the buffer for client/server communication\&. The maximum is 1GB\&.
  2037. .RE
  2038. .sp
  2039. .RS 4
  2040. .ie n \{\
  2041. \h'-04'\(bu\h'+03'\c
  2042. .\}
  2043. .el \{\
  2044. .sp -1
  2045. .IP \(bu 2.3
  2046. .\}
  2047. net_buffer_length
  2048. .sp
  2049. The initial size of the buffer for client/server communication\&. When creating multiple\-row
  2050. INSERT
  2051. statements (as with the
  2052. \fB\-\-extended\-insert\fR
  2053. or
  2054. \fB\-\-opt\fR
  2055. option),
  2056. \fBmysqldump\fR
  2057. creates rows up to
  2058. net_buffer_length
  2059. length\&. If you increase this variable, you should also ensure that the
  2060. net_buffer_length
  2061. variable in the MySQL server is at least this large\&.
  2062. .RE
  2063. .PP
  2064. A common use of
  2065. \fBmysqldump\fR
  2066. is for making a backup of an entire database:
  2067. .sp
  2068. .if n \{\
  2069. .RS 4
  2070. .\}
  2071. .nf
  2072. shell> \fBmysqldump \fR\fB\fIdb_name\fR\fR\fB > \fR\fB\fIbackup\-file\&.sql\fR\fR
  2073. .fi
  2074. .if n \{\
  2075. .RE
  2076. .\}
  2077. .PP
  2078. You can load the dump file back into the server like this:
  2079. .sp
  2080. .if n \{\
  2081. .RS 4
  2082. .\}
  2083. .nf
  2084. shell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fIbackup\-file\&.sql\fR\fR
  2085. .fi
  2086. .if n \{\
  2087. .RE
  2088. .\}
  2089. .PP
  2090. Or like this:
  2091. .sp
  2092. .if n \{\
  2093. .RS 4
  2094. .\}
  2095. .nf
  2096. shell> \fBmysql \-e "source \fR\fB\fI/path\-to\-backup/backup\-file\&.sql\fR\fR\fB" \fR\fB\fIdb_name\fR\fR
  2097. .fi
  2098. .if n \{\
  2099. .RE
  2100. .\}
  2101. .PP
  2102. \fBmysqldump\fR
  2103. is also very useful for populating databases by copying data from one MySQL server to another:
  2104. .sp
  2105. .if n \{\
  2106. .RS 4
  2107. .\}
  2108. .nf
  2109. shell> \fBmysqldump \-\-opt \fR\fB\fIdb_name\fR\fR\fB | mysql \-\-host=\fR\fB\fIremote_host\fR\fR\fB \-C \fR\fB\fIdb_name\fR\fR
  2110. .fi
  2111. .if n \{\
  2112. .RE
  2113. .\}
  2114. .PP
  2115. It is possible to dump several databases with one command:
  2116. .sp
  2117. .if n \{\
  2118. .RS 4
  2119. .\}
  2120. .nf
  2121. shell> \fBmysqldump \-\-databases \fR\fB\fIdb_name1\fR\fR\fB [\fR\fB\fIdb_name2\fR\fR\fB \&.\&.\&.] > my_databases\&.sql\fR
  2122. .fi
  2123. .if n \{\
  2124. .RE
  2125. .\}
  2126. .PP
  2127. To dump all databases, use the
  2128. \fB\-\-all\-databases\fR
  2129. option:
  2130. .sp
  2131. .if n \{\
  2132. .RS 4
  2133. .\}
  2134. .nf
  2135. shell> \fBmysqldump \-\-all\-databases > all_databases\&.sql\fR
  2136. .fi
  2137. .if n \{\
  2138. .RE
  2139. .\}
  2140. .PP
  2141. For
  2142. InnoDB
  2143. tables,
  2144. \fBmysqldump\fR
  2145. provides a way of making an online backup:
  2146. .sp
  2147. .if n \{\
  2148. .RS 4
  2149. .\}
  2150. .nf
  2151. shell> \fBmysqldump \-\-all\-databases \-\-single\-transaction > all_databases\&.sql\fR
  2152. .fi
  2153. .if n \{\
  2154. .RE
  2155. .\}
  2156. .PP
  2157. This backup acquires a global read lock on all tables (using
  2158. FLUSH TABLES WITH READ LOCK) at the beginning of the dump\&. As soon as this lock has been acquired, the binary log coordinates are read and the lock is released\&. If long updating statements are running when the
  2159. FLUSH
  2160. statement is issued, the MySQL server may get stalled until those statements finish\&. After that, the dump becomes lock free and does not disturb reads and writes on the tables\&. If the update statements that the MySQL server receives are short (in terms of execution time), the initial lock period should not be noticeable, even with many updates\&.
  2161. .PP
  2162. For point\-in\-time recovery (also known as
  2163. \(lqroll\-forward,\(rq
  2164. when you need to restore an old backup and replay the changes that happened since that backup), it is often useful to rotate the binary log (see
  2165. Section\ \&5.2.4, \(lqThe Binary Log\(rq) or at least know the binary log coordinates to which the dump corresponds:
  2166. .sp
  2167. .if n \{\
  2168. .RS 4
  2169. .\}
  2170. .nf
  2171. shell> \fBmysqldump \-\-all\-databases \-\-master\-data=2 > all_databases\&.sql\fR
  2172. .fi
  2173. .if n \{\
  2174. .RE
  2175. .\}
  2176. .PP
  2177. Or:
  2178. .sp
  2179. .if n \{\
  2180. .RS 4
  2181. .\}
  2182. .nf
  2183. shell> \fBmysqldump \-\-all\-databases \-\-flush\-logs \-\-master\-data=2\fR
  2184. \fB> all_databases\&.sql\fR
  2185. .fi
  2186. .if n \{\
  2187. .RE
  2188. .\}
  2189. .PP
  2190. The
  2191. \fB\-\-master\-data\fR
  2192. and
  2193. \fB\-\-single\-transaction\fR
  2194. options can be used simultaneously, which provides a convenient way to make an online backup suitable for use prior to point\-in\-time recovery if tables are stored using the
  2195. InnoDB
  2196. storage engine\&.
  2197. .PP
  2198. For more information on making backups, see
  2199. Section\ \&6.2, \(lqDatabase Backup Methods\(rq, and
  2200. Section\ \&6.3, \(lqExample Backup and Recovery Strategy\(rq\&.
  2201. .\" mysqldump: views
  2202. .\" mysqldump: problems
  2203. .\" mysqldump: workarounds
  2204. .PP
  2205. If you encounter problems backing up views, please read the section that covers restrictions on views which describes a workaround for backing up views when this fails due to insufficient privileges\&. See
  2206. Section\ \&D.4, \(lqRestrictions on Views\(rq\&.
  2207. .SH "COPYRIGHT"
  2208. .br
  2209. .PP
  2210. Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
  2211. .PP
  2212. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
  2213. .PP
  2214. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  2215. .PP
  2216. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
  2217. .sp
  2218. .SH "NOTES"
  2219. .IP " 1." 4
  2220. Bug#30123
  2221. .RS 4
  2222. \%http://bugs.mysql.com/bug.php?id=30123
  2223. .RE
  2224. .SH "SEE ALSO"
  2225. For more information, please refer to the MySQL Reference Manual,
  2226. which may already be installed locally and which is also available
  2227. online at http://dev.mysql.com/doc/.
  2228. .SH AUTHOR
  2229. Sun Microsystems, Inc. (http://www.mysql.com/).