1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
|
'\" t
.\" Title: \fBmysqldbexport\fR
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 08/30/2013
.\" Manual: MySQL Utilities
.\" Source: MySQL 1.3.4
.\" Language: English
.\"
.TH "\FBMYSQLDBEXPORT\FR" "1" "08/30/2013" "MySQL 1\&.3\&.4" "MySQL Utilities"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.\" mysqldbexport
.\" utilities: mysqldbexport
.\" scripts
.SH "NAME"
mysqldbexport \- Export Object Definitions or Data from a Database
.SH "SYNOPSIS"
.HP \w'\fBmysqldbexport\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fIdb_name\fR\fR\fB\ \&.\&.\&.\fR\ 'u
\fBmysqldbexport [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB \&.\&.\&.\fR
.SH "DESCRIPTION"
.PP
This utility exports metadata (object definitions) or data or both from one or more databases\&. By default, the export includes only definitions\&.
.PP
\fBmysqldbexport\fR
differs from
\fBmysqldump\fR
in that it can produce output in a variety of formats to make your data extraction/transport much easier\&. It permits you to export your data in the format most suitable to an external tool, another MySQL server, or other use without the need to reformat the data\&.
.PP
To exclude specific objects by name, use the
\fB\-\-exclude\fR
option with a name in
\fIdb\fR\&.*obj* format, or you can supply a search pattern\&. For example,
\fB\-\-exclude=db1\&.trig1\fR
excludes the single trigger and
\fB\-\-exclude=trig_\fR
excludes all objects from all databases having a name that begins with
trig
and has a following character\&.
.PP
To skip objects by type, use the
\fB\-\-skip\fR
option with a list of the objects to skip\&. This enables you to extract a particular set of objects, say, for exporting only events (by excluding all other types)\&. Similarly, to skip creation of
\fBUPDATE\fR
statements for
BLOB
data, specify the
\fB\-\-skip\-blobs\fR
option\&.
.PP
To specify how to display output, use one of the following values with the
\fB\-\-format\fR
option:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBsql\fR
(default)
.sp
Display output using SQL statements\&. For definitions, this consists of the appropriate
\fBCREATE\fR
and
\fBGRANT\fR
statements\&. For data, this is an
\fBINSERT\fR
statement (or bulk insert if the
\fB\-\-bulk\-insert\fR
option is specified)\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBgrid\fR
.sp
Display output in grid or table format like that of the
\fBmysql\fR
monitor\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBcsv\fR
.sp
Display output in comma\-separated values format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBtab\fR
.sp
Display output in tab\-separated format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBvertical\fR
.sp
Display output in single\-column format like that of the
\eG
command for the
\fBmysql\fR
monitor\&.
.RE
.PP
To specify how much data to display, use one of the following values with the
\fB\-\-display\fR
option:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBbrief\fR
.sp
Display only the minimal columns for recreating the objects\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBfull\fR
.sp
Display the complete column list for recreating the objects\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBnames\fR
.sp
Display only the object names\&.
.RE
.PP
Note: For SQL\-format output, the
\fB\-\-display\fR
option is ignored\&.
.PP
To turn off the headers for
\fBcsv\fR
or
\fBtab\fR
display format, specify the
\fB\-\-no\-headers\fR
option\&.
.PP
To turn off all feedback information, specify the
\fB\-\-quiet\fR
option\&.
.PP
To write the data for individual tables to separate files, use the
\fB\-\-file\-per\-table\fR
option\&. The name of each file is composed of the database and table names followed by the file format\&. For example, the following command produces files named db1\&.*table_name*\&.csv:
.sp
.if n \{\
.RS 4
.\}
.nf
mysqldbexport \-\-server=root@server1:3306 \-\-format=csv db1 \-\-export=data
.fi
.if n \{\
.RE
.\}
.PP
By default, the operation uses a consistent snapshot to read the source databases\&. To change the locking mode, use the
\fB\-\-locking\fR
option with a locking type value\&. Use a value of
\fBno\-locks\fR
to turn off locking altogether or
\fBlock\-all\fR
to use only table locks\&. The default value is
\fBsnapshot\fR\&. Additionally, the utility uses WRITE locks to lock the destination tables during the copy\&.
.PP
You can include replication statements for exporting data among a master and slave or between slaves\&. The
\fB\-\-rpl\fR
option permits you to select from the following replication statements to include in the export\&.
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBmaster\fR
.sp
Include the
\fBCHANGE MASTER\fR
statement to start a new slave with the current server acting as the master\&. This places the appropriate STOP and START slave statements in the export whereby the
\fBSTOP SLAVE\fR
statement is placed at the start of the export and the
\fBCHANGE MASTER\fR
followed by the
\fBSTART SLAVE\fR
statements are placed after the export stream\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBslave\fR
.sp
Include the
\fBCHANGE MASTER\fR
statement to start a new slave using the current server\*(Aqs master information\&. This places the appropriate STOP and START slave statements in the export whereby the
\fBSTOP SLAVE\fR
statement is placed at the start of the export and the
\fBCHANGE MASTER\fR
followed by the
\fBSTART SLAVE\fR
statements are placed after the export stream\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBboth\fR
.sp
Include both the \*(Aqmaster\*(Aq and \*(Aqslave\*(Aq information for
\fBCHANGE MASTER\fR
statements for either spawning a new slave with the current server\*(Aqs master or using the current server as the master\&. All statements generated are labeled and commented to enable the user to choose which to include when imported\&.
.RE
.PP
To include the replication user in the
\fBCHANGE MASTER\fR
statement, use the
\fB\-\-rpl\-user\fR
option to specify the user and password\&. If this option is omitted, the utility attempts to identify the replication user\&. In the event that there are multiple candidates or the user requires a password, these statements are placed inside comments for the
\fBCHANGE MASTER\fR
statement\&.
.PP
You can also use the
\fB\-\-comment\-rpl\fR
option to place the replication statements inside comments for later examination\&.
.PP
If you specify the
\fB\-\-rpl\-file\fR
option, the utility writes the replication statements to the file specified instead of including them in the export stream\&.
.PP
If you attempt to export databases on a server with GTIDs enabled (GTID_MODE = ON), a warning will be generated if the export does not include all databases\&. This is because the GTID statements generated include the GTIDs for all databases and not only those databases in the export\&.
.PP
The utility will also generate a warning if you export databases on a GTID enabled server but use the
\fB\-\-skip\-gtid \fR
option\&.
.PP
To make the most use of GTIDs and export/import, you should export all of the databases on the server with the
\fB\-\-all\fR
option\&. This will generate an export file with all of the databases and the GTIDs executed to that point\&.
.PP
Importing this file on another server will ensure that server has all of the data as well as all of the GTIDs recorded correctly in its logs\&.
OPTIONS
.PP
\fBmysqldbexport\fR
accepts the following command\-line options:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-help
.sp
Display a help message and exit\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-bulk\-insert, \-b
.sp
Use bulk insert statements for data\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-comment\-rpl
.sp
Place the replication statements in comment statements\&. Valid only with the
\fB\-\-rpl\fR
option\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-display=<display>, \-d<display>
.sp
Control the number of columns shown\&. Permitted display values are
\fBbrief\fR
(minimal columns for object creation),
\fBfull* (all columns), and **names\fR
(only object names; not valid for
\fB\-\-format=sql\fR)\&. The default is
\fBbrief\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-exclude=<exclude>, \-x<exclude>
.sp
Exclude one or more objects from the operation using either a specific name such as
db1\&.t1
or a search pattern\&. Use this option multiple times to specify multiple exclusions\&. By default, patterns use
\fBLIKE\fR
matching\&. With the
\fB\-\-regexp\fR
option, patterns use
\fBREGEXP\fR
matching\&.
.sp
This option does not apply to grants\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-export=<export>, \-e<export>
.sp
Specify the export format\&. Permitted format values are
\fBdefinitions\fR
= export only the definitions (metadata) for the objects in the database list,
\fBdata\fR
= export only the table data for the tables in the database list, and
\fBboth\fR
= export the definitions and the data\&. The default is
\fBdefinitions\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-file\-per\-table
.sp
Write table data to separate files\&. This is Valid only if the export output includes data (that is, if
\fB\-\-export=data\fR
or
\fB\-\-export=both\fR
are given)\&. This option produces files named
\fIdb_name\fR\&.*tbl_name*\&.*format*\&. For example, a
\fBcsv\fR
export of two tables named
t1
and
t2
in database
d1, results in files named
db1\&.t1\&.csv
and
db1\&.t2\&.csv\&. If table definitions are included in the export, they are written to stdout as usual\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-format=<format>, \-f<format>
.sp
Specify the output display format\&. Permitted format values are
\fBsql\fR,
\fBgrid\fR,
\fBtab\fR,
\fBcsv\fR, and
\fBvertical\fR\&. The default is
\fBsql\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-locking=<locking>
.sp
Choose the lock type for the operation\&. Permitted lock values are
\fBno\-locks\fR
(do not use any table locks),
\fBlock\-all\fR
(use table locks but no transaction and no consistent read), and
\fBsnapshot\fR
(consistent read using a single transaction)\&. The default is
\fBsnapshot\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-no\-headers, \-h
.sp
Do not display column headers\&. This option applies only for
\fBcsv\fR
and
\fBtab\fR
output\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-quiet, \-q
.sp
Turn off all messages for quiet execution\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-regexp, \-\-basic\-regexp, \-G
.sp
Perform pattern matches using the
\fBREGEXP\fR
operator\&. The default is to use
\fBLIKE\fR
for matching\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-rpl=<dump_option>, \-\-replication=<dump_option>
.sp
Include replication information\&. Permitted values are
\fBmaster\fR
(include the
\fBCHANGE MASTER\fR
statement using the source server as the master),
\fBslave\fR
(include the
\fBCHANGE MASTER\fR
statement using the destination server\*(Aqs master information), and
\fBboth\fR
(include the
\fBmaster\fR
and
\fBslave\fR
options where applicable)\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-rpl\-file=RPL_FILE, \-\-replication\-file=RPL_FILE
.sp
The path and file name where the generated replication information should be written\&. Valid only with the
\fB\-\-rpl\fR
option\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-rpl\-user=<replication_user>
.sp
The user and password for the replication user requirement, in the format: <\fIuser\fR>[:<\fIpassword\fR>] or <\fIlogin\-path\fR>\&. For example,
rpl:passwd\&. The default is None\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-server=<server>
.sp
Connection information for the server in <\fIuser\fR>[:<\fIpasswd\fR>]@<\fIhost\fR>[:<\fIport\fR>][:<\fIsocket\fR>] or <\fIlogin\-path\fR>[::<\fIport\fR>][::<\fIsocket\fR>]\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip=<skip\-objects>
.sp
Specify objects to skip in the operation as a comma\-separated list (no spaces)\&. Permitted values are
\fBCREATE_DB\fR,
\fBDATA\fR,
\fBEVENTS\fR,
\fBFUNCTIONS\fR,
\fBGRANTS\fR,
\fBPROCEDURES\fR,
\fBTABLES\fR,
\fBTRIGGERS\fR, and
\fBVIEWS\fR\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-blobs
.sp
Do not export
BLOB
data\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-gtid
.sp
Skip creation of GTID_PURGED statements\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-all
.sp
Generate an export file with all of the databases and the GTIDs executed to that point\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-verbose, \-v
.sp
Specify how much information to display\&. Use this option multiple times to increase the amount of information\&. For example,
\fB\-v\fR
= verbose,
\fB\-vv\fR
= more verbose,
\fB\-vvv\fR
= debug\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-version
.sp
Display version information and exit\&.
.RE
NOTES
.PP
You must provide connection parameters (user, host, password, and so forth) for an account that has the appropriate privileges to access all objects in the operation\&.
.PP
To export all objects from a source database, the user must have these privileges:
\fBSELECT\fR
and
\fBSHOW VIEW\fR
on the database as well as
\fBSELECT\fR
on the
mysql
database\&.
.PP
Actual privileges needed may differ from installation to installation depending on the security privileges present and whether the database contains certain objects such as views or events\&.
.PP
Some combinations of the options may result in errors when the export is imported later\&. For example, eliminating tables but not views may result in an error when a view is imported on another server\&.
.PP
For the
\fB\-\-format\fR,
\fB\-\-export\fR, and
\fB\-\-display\fR
options, the permitted values are not case sensitive\&. In addition, values may be specified as any unambiguous prefix of a valid value\&. For example,
\fB\-\-format=g\fR
specifies the grid format\&. An error occurs if a prefix matches more than one valid value\&.
.PP
The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login\-paths\&. This will allow the utility to use the my_print_defaults tools which is required to read the login\-path values from the login configuration file (\&.mylogin\&.cnf)\&.
.PP
If any database identifier specified as an argument contains special characters or is a reserved word, then it must be appropriately quoted with backticks (\fB`\fR)\&. In turn, names quoted with backticks must also be quoted with single or double quotes depending on the operating system, i\&.e\&. (\fB"\fR) in Windows or (\fB\*(Aq\fR) in non\-Windows systems, in order for the utilities to read backtick quoted identifiers as a single argument\&. For example, to export a database with the name
\fBweird`db\&.name\fR, it must be specified as argument using the following syntax (in non\-Windows):
\fB\*(Aq`weird``db\&.name`\*(Aq\fR\&.
EXAMPLES
.PP
To export the definitions of the database
dev
from a MySQL server on the local host via port 3306, producing output consisting of
\fBCREATE\fR
statements, use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbexport \-\-server=root:pass@localhost \e
\-\-skip=GRANTS \-\-export=DEFINITIONS util_test
# Source on localhost: \&.\&.\&. connected\&.
# Exporting metadata from util_test
DROP DATABASE IF EXISTS util_test;
CREATE DATABASE util_test;
USE util_test;
# TABLE: util_test\&.t1
CREATE TABLE `t1` (
`a` char(30) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
# TABLE: util_test\&.t2
CREATE TABLE `t2` (
`a` char(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
# TABLE: util_test\&.t3
CREATE TABLE `t3` (
`a` int(11) NOT NULL AUTO_INCREMENT,
`b` char(30) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
# TABLE: util_test\&.t4
CREATE TABLE `t4` (
`c` int(11) NOT NULL,
`d` int(11) NOT NULL,
KEY `ref_t3` (`c`),
CONSTRAINT `ref_t3` FOREIGN KEY (`c`) REFERENCES `t3` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# VIEW: util_test\&.v1
[\&.\&.\&.]
#\&.\&.\&.done\&.
.fi
.if n \{\
.RE
.\}
.PP
Similarly, to export the data of the database
util_test, producing bulk insert statements, use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbexport \-\-server=root:pass@localhost \e
\-\-export=DATA \-\-bulk\-insert util_test
# Source on localhost: \&.\&.\&. connected\&.
USE util_test;
# Exporting data from util_test
# Data for table util_test\&.t1:
INSERT INTO util_test\&.t1 VALUES (\*(Aq01 Test Basic database example\*(Aq),
(\*(Aq02 Test Basic database example\*(Aq),
(\*(Aq03 Test Basic database example\*(Aq),
(\*(Aq04 Test Basic database example\*(Aq),
(\*(Aq05 Test Basic database example\*(Aq),
(\*(Aq06 Test Basic database example\*(Aq),
(\*(Aq07 Test Basic database example\*(Aq);
# Data for table util_test\&.t2:
INSERT INTO util_test\&.t2 VALUES (\*(Aq11 Test Basic database example\*(Aq),
(\*(Aq12 Test Basic database example\*(Aq),
(\*(Aq13 Test Basic database example\*(Aq);
# Data for table util_test\&.t3:
INSERT INTO util_test\&.t3 VALUES (1, \*(Aq14 test fkeys\*(Aq),
(2, \*(Aq15 test fkeys\*(Aq),
(3, \*(Aq16 test fkeys\*(Aq);
# Data for table util_test\&.t4:
INSERT INTO util_test\&.t4 VALUES (3, 2);
#\&.\&.\&.done\&.
.fi
.if n \{\
.RE
.\}
.PP
If the database to be exported does not contain only InnoDB tables and you want to ensure data integrity of the exported data by locking the tables during the read step, add a
\fB\-\-locking=lock\-all\fR
option to the command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbexport \-\-server=root:pass@localhost \e
\-\-export=DATA \-\-bulk\-insert util_test \-\-locking=lock\-all
# Source on localhost: \&.\&.\&. connected\&.
USE util_test;
# Exporting data from util_test
# Data for table util_test\&.t1:
INSERT INTO util_test\&.t1 VALUES (\*(Aq01 Test Basic database example\*(Aq),
(\*(Aq02 Test Basic database example\*(Aq),
(\*(Aq03 Test Basic database example\*(Aq),
(\*(Aq04 Test Basic database example\*(Aq),
(\*(Aq05 Test Basic database example\*(Aq),
(\*(Aq06 Test Basic database example\*(Aq),
(\*(Aq07 Test Basic database example\*(Aq);
# Data for table util_test\&.t2:
INSERT INTO util_test\&.t2 VALUES (\*(Aq11 Test Basic database example\*(Aq),
(\*(Aq12 Test Basic database example\*(Aq),
(\*(Aq13 Test Basic database example\*(Aq);
# Data for table util_test\&.t3:
INSERT INTO util_test\&.t3 VALUES (1, \*(Aq14 test fkeys\*(Aq),
(2, \*(Aq15 test fkeys\*(Aq),
(3, \*(Aq16 test fkeys\*(Aq);
# Data for table util_test\&.t4:
INSERT INTO util_test\&.t4 VALUES (3, 2);
#\&.\&.\&.done\&.
.fi
.if n \{\
.RE
.\}
.PP
To export a database and include the replication commands to use the current server as the master (for example, to start a new slave using the current server as the master), use the following command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbexport \-\-server=root@localhost:3311 util_test \e
\-\-export=both \-\-rpl\-user=rpl:rpl \-\-rpl=master \-v
# Source on localhost: \&.\&.\&. connected\&.
#
# Stopping slave
STOP SLAVE;
#
# Source on localhost: \&.\&.\&. connected\&.
# Exporting metadata from util_test
DROP DATABASE IF EXISTS util_test;
CREATE DATABASE util_test;
USE util_test;
# TABLE: util_test\&.t1
CREATE TABLE `t1` (
`a` char(30) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
#\&.\&.\&.done\&.
# Source on localhost: \&.\&.\&. connected\&.
USE util_test;
# Exporting data from util_test
# Data for table util_test\&.t1:
INSERT INTO util_test\&.t1 VALUES (\*(Aq01 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq02 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq03 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq04 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq05 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq06 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq07 Test Basic database example\*(Aq);
#\&.\&.\&.done\&.
#
# Connecting to the current server as master
CHANGE MASTER TO MASTER_HOST = \*(Aqlocalhost\*(Aq,
MASTER_USER = \*(Aqrpl\*(Aq,
MASTER_PASSWORD = \*(Aqrpl\*(Aq,
MASTER_PORT = 3311,
MASTER_LOG_FILE = \*(Aqclone\-bin\&.000001\*(Aq ,
MASTER_LOG_POS = 106;
#
# Starting slave
START SLAVE;
#
.fi
.if n \{\
.RE
.\}
.PP
Similarly, to export a database and include the replication commands to use the current server\*(Aqs master (for example, to start a new slave using the same the master), use the following command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbexport \-\-server=root@localhost:3311 util_test \e
\-\-export=both \-\-rpl\-user=rpl:rpl \-\-rpl=slave \-v
# Source on localhost: \&.\&.\&. connected\&.
#
# Stopping slave
STOP SLAVE;
#
# Source on localhost: \&.\&.\&. connected\&.
# Exporting metadata from util_test
DROP DATABASE IF EXISTS util_test;
CREATE DATABASE util_test;
USE util_test;
# TABLE: util_test\&.t1
CREATE TABLE `t1` (
`a` char(30) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
#\&.\&.\&.done\&.
# Source on localhost: \&.\&.\&. connected\&.
USE util_test;
# Exporting data from util_test
# Data for table util_test\&.t1:
INSERT INTO util_test\&.t1 VALUES (\*(Aq01 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq02 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq03 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq04 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq05 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq06 Test Basic database example\*(Aq);
INSERT INTO util_test\&.t1 VALUES (\*(Aq07 Test Basic database example\*(Aq);
#\&.\&.\&.done\&.
#
# Connecting to the current server\*(Aqs master
CHANGE MASTER TO MASTER_HOST = \*(Aqlocalhost\*(Aq,
MASTER_USER = \*(Aqrpl\*(Aq,
MASTER_PASSWORD = \*(Aqrpl\*(Aq,
MASTER_PORT = 3310,
MASTER_LOG_FILE = \*(Aqclone\-bin\&.000001\*(Aq ,
MASTER_LOG_POS = 1739;
#
# Starting slave
START SLAVE;
#
.fi
.if n \{\
.RE
.\}
.SH "COPYRIGHT"
.br
.SH "SEE ALSO"
For more information, please refer to the MySQL Utilities section
of the MySQL Workbench Reference Manual, which is available online
at http://dev.mysql.com/doc/workbench/en/.
.SH AUTHOR
Oracle Corporation (http://dev.mysql.com/).
|