File: mysqldbimport.1

package info (click to toggle)
mysql-utilities 1.3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,100 kB
  • ctags: 1,681
  • sloc: python: 19,938; makefile: 34
file content (568 lines) | stat: -rw-r--r-- 13,600 bytes parent folder | download
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
'\" t
.\"     Title: \fBmysqldbimport\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 "\FBMYSQLDBIMPORT\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 *
.\" -----------------------------------------------------------------
.\" mysqldbimport
.\" utilities: mysqldbimport
.\" scripts
.SH "NAME"
mysqldbimport \- Import Object Definitions or Data into a Databases
.SH "SYNOPSIS"
.HP \w'\fBmysqldbimport\ [\fR\fB\fIoptions\fR\fR\fB]\ \fR\fB\fIimport_file\fR\fR\fB\ \&.\&.\&.\fR\ 'u
\fBmysqldbimport [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIimport_file\fR\fR\fB \&.\&.\&.\fR
.SH "DESCRIPTION"
.PP
This utility imports metadata (object definitions) or data or both for one or more databases from one or more files\&.
.PP
If an object exists on the destination server with the same name as an imported object, it is dropped first before importing the new object\&.
.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 importing 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 the input format, use one of the following values with the
\fB\-\-format\fR
option\&. These correspond to the output formats of the
\fBmysqldbexport\fR
utility:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBsql\fR
(default)
.sp
Input consists of 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
Input is formatted in comma\-separated values format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBraw_csv\fR
.sp
Input is a simple CSV file containing uniform rows with values separated with commas\&. The file can contain a header (the first row) that lists the table columns\&. The option
\fB\-\-table\fR
is required to use this format\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBtab\fR
.sp
Input is formatted 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 indicate that input in
\fBcsv\fR
or
\fBtab\fR
format does not contain column headers, specify the
\fB\-\-no\-headers\fR
option\&.
.PP
To turn off all feedback information, specify the
\fB\-\-quiet\fR
option\&.
.PP
By default, the utility creates each table on the destination server using the same storage engine as the original table\&. To override this and specify the storage engine to use for all tables created on the destination server, use the
\fB\-\-new\-storage\-engine\fR
option\&. If the destination server supports the new engine, all tables use that engine\&.
.PP
To specify the storage engine to use for tables for which the destination server does not support the original storage engine on the source server, use the
\fB\-\-default\-storage\-engine\fR
option\&.
.PP
The
\fB\-\-new\-storage\-engine\fR
option takes precedence over
\fB\-\-default\-storage\-engine\fR
if both are given\&.
.PP
If the
\fB\-\-new\-storage\-engine\fR
or
\fB\-\-default\-storage\-engine\fR
option is given and the destination server does not support the specified storage engine, a warning is issued and the server\*(Aqs default storage engine setting is used instead\&.
.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\&. For details, see NOTES\&.
.PP
If you attempt to import databases on a server with GTIDs enabled (GTID_MODE = ON), a warning will be generated if the import file did not include the GTID statements generated by mysqldbexport\&.
.PP
The utility will also generate a warning if you import databases on a server without GTIDs enabled and there are GTID statements present in the file\&. Use the
\fB\-\-skip\-gtid\fR
option to ignore the GTID statements\&.
.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\&. 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
\fBmysqldbimport\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
.\}
\-\-default\-storage\-engine=<def_engine>
.sp
The engine to use for tables if the destination server does not support the original storage engine on the source server\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-drop\-first, \-d
.sp
Drop each database to be imported if exists before importing anything into it\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-dryrun
.sp
Import the files and generate the statements but do not execute them\&. This is useful for testing input file validity\&.
.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 input format\&. Permitted format values are
\fBsql\fR,
\fBgrid\fR,
\fBtab\fR,
\fBcsv\fR,
\fBraw_csv\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
.\}
\-\-import=<import_type>, \-i<import_type>
.sp
Specify the import format\&. Permitted format values are
\fBdefinitions\fR
= import only the definitions (metadata) for the objects in the database list,
\fBdata\fR
= import only the table data for the tables in the database list, and
\fBboth\fR
= import the definitions and the data\&. The default is
\fBdefinitions\fR\&.
.sp
If you attempt to import objects into an existing database, the result depends on the import format\&. If the format is
\fBdefinitions\fR
or
\fBboth\fR, an error occurs unless
\fB\-\-drop\-first\fR
is given\&. If the format is
\fBdata\fR, imported table data is added to existing table data\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-new\-storage\-engine=<new_engine>
.sp
The engine to use for all tables created on the destination server\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-no\-headers, \-h
.sp
Input does not contain 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
.\}
\-\-server=<server>
.sp
Connection information for the server in the format: <\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 import
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 execution of GTID_PURGED statements\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-skip\-rpl
.sp
Do not execute replication commands\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\-\-table=<db>,<table>
.sp
Specify the table for importing\&. This option is required while using
\fB\-\-format=raw_csv\fR\&.
.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
The login user must have the appropriate permissions to create new objects, access (read) the
mysql
database, and grant privileges\&. If a database to be imported already exists, the user must have read permission for it, which is needed to check the existence of objects in the 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 and whether binary logging is enabled\&.
.PP
Some combinations of the options may result in errors during the operation\&. For example, excluding tables but not views may result in an error when a view is imported\&.
.PP
The
\fB\-\-new\-storage\-engine\fR
and
\fB\-\-default\-storage\-engine\fR
options apply to all destination tables in the operation\&.
.PP
For the
\fB\-\-format\fR
and
\fB\-\-import\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
When importing data and including the GTID commands, you may encounter an error similar to "GTID_PURGED can only be set when GTID_EXECUTED is empty"\&. This occurs because the destination server is not in a clean replication state\&. To aleviate this problem, you can issue a "RESET MASTER" command on the destination prior to executing the import\&.
.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)\&.
      EXAMPLES
.PP
To import the metadata from the
util_test
database to the server on the local host using a file in CSV format, use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbimport \-\-server=root@localhost \-\-import=definitions \e
  \-\-format=csv data\&.csv
# Source on localhost: \&.\&.\&. connected\&.
# Importing definitions from data\&.csv\&.
#\&.\&.\&.done\&.
.fi
.if n \{\
.RE
.\}
.PP
Similarly, to import the data from the
util_test
database to the server on the local host, importing the data using bulk insert statements, use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbimport \-\-server=root@localhost \-\-import=data \e
  \-\-bulk\-insert \-\-format=csv data\&.csv
# Source on localhost: \&.\&.\&. connected\&.
# Importing data from data\&.csv\&.
#\&.\&.\&.done\&.
.fi
.if n \{\
.RE
.\}
.PP
To import both data and definitions from the
util_test
database, importing the data using bulk insert statements from a file that contains SQL statements, use this command:
.sp
.if n \{\
.RS 4
.\}
.nf
$ mysqldbimport \-\-server=root@localhost \-\-import=both \-\-bulk\-insert \-\-format=sql data\&.sql
# Source on localhost: \&.\&.\&. connected\&.
# Importing definitions and data from data\&.sql\&.
#\&.\&.\&.done\&.
.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/).