1
.\" Title: \fBmysqlimport\fR
3
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
5
.\" Manual: MySQL Database System
8
.TH "\fBMYSQLIMPORT\fR" "1" "05/23/2009" "MySQL 6.0" "MySQL Database System"
9
.\" disable hyphenation
11
.\" disable justification (adjust text to left margin only)
14
mysqlimport \- a data import program
17
\fBmysqlimport [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB \fR\fB\fItextfile1\fR\fR\fB ...\fR
22
client provides a command\-line interface to the
24
SQL statement. Most options to
26
correspond directly to clauses of
29
Section\ 12.2.6, \(lqLOAD DATA INFILE Syntax\(rq.
37
shell> \fBmysqlimport [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB \fR\fB\fItextfile1\fR\fR\fB [\fR\fB\fItextfile2\fR\fR\fB ...]\fR
41
For each text file named on the command line,
43
strips any extension from the file name and uses the result to determine the name of the table into which to import the file's contents. For example, files named
45
\fIpatient.text\fR, and
47
all would be imported into a table named
51
supports the options in the following list. It also reads option files and supports the options for processing them described at
52
Section\ 4.2.3.2.1, \(lqCommand\-Line Options that Affect Option\-File Handling\(rq.
58
Display a help message and exit.
61
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
63
The directory where character sets are installed. See
64
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
67
\fB\-\-columns=\fR\fB\fIcolumn_list\fR\fR,
68
\fB\-c \fR\fB\fIcolumn_list\fR\fR
70
This option takes a comma\-separated list of column names as its value. The order of the column names indicates how to match data file columns with table columns.
76
Compress all information sent between the client and the server if both support compression.
79
\fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
80
\fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
82
Write a debugging log. A typical
85
\'d:t:o,\fIfile_name\fR'. The default is
89
\fB\-\-debug\-check\fR
91
Print some debugging information when the program exits.
96
Print debugging information and memory and CPU usage statistics when the program exits.
99
\fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR
103
as the default character set. See
104
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
110
Empty the table before importing the text file.
113
\fB\-\-fields\-terminated\-by=...\fR,
114
\fB\-\-fields\-enclosed\-by=...\fR,
115
\fB\-\-fields\-optionally\-enclosed\-by=...\fR,
116
\fB\-\-fields\-escaped\-by=...\fR
118
These options have the same meaning as the corresponding clauses for
119
LOAD DATA INFILE. See
120
Section\ 12.2.6, \(lqLOAD DATA INFILE Syntax\(rq.
126
Ignore errors. For example, if a table for a text file does not exist, continue processing any remaining files. Without
129
exits if a table does not exist.
132
\fB\-\-host=\fR\fB\fIhost_name\fR\fR,
133
\fB\-h \fR\fB\fIhost_name\fR\fR
135
Import data to the MySQL server on the given host. The default host is
142
See the description for the
147
\fB\-\-ignore\-lines=\fR\fB\fIN\fR\fR
151
lines of the data file.
154
\fB\-\-lines\-terminated\-by=...\fR
156
This option has the same meaning as the corresponding clause for
157
LOAD DATA INFILE. For example, to import Windows files that have lines terminated with carriage return/linefeed pairs, use
158
\fB\-\-lines\-terminated\-by="\\r\\n"\fR. (You might have to double the backslashes, depending on the escaping conventions of your command interpreter.) See
159
Section\ 12.2.6, \(lqLOAD DATA INFILE Syntax\(rq.
165
Read input files locally from the client host.
168
\fB\-\-lock\-tables\fR,
173
tables for writing before processing any text files. This ensures that all tables are synchronized on the server.
176
\fB\-\-low\-priority\fR
180
when loading the table. This affects only storage engines that use only table\-level locking (MyISAM,
185
\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
186
\fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
188
The password to use when connecting to the server. If you use the short option form (\fB\-p\fR), you
190
have a space between the option and the password. If you omit the
196
option on the command line, you are prompted for one.
198
Specifying a password on the command line should be considered insecure. See
199
Section\ 5.5.6.2, \(lqEnd\-User Guidelines for Password Security\(rq.
205
On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named\-pipe connections.
208
\fB\-\-port=\fR\fB\fIport_num\fR\fR,
209
\fB\-P \fR\fB\fIport_num\fR\fR
211
The TCP/IP port number to use for the connection.
214
\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
216
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
217
Section\ 4.2.2, \(lqConnecting to the MySQL Server\(rq.
227
options control handling of input rows that duplicate existing rows on unique key values. If you specify
228
\fB\-\-replace\fR, new rows replace existing rows that have the same unique key value. If you specify
229
\fB\-\-ignore\fR, input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored.
235
Silent mode. Produce output only when errors occur.
238
\fB\-\-socket=\fR\fB\fIpath\fR\fR,
239
\fB\-S \fR\fB\fIpath\fR\fR
242
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
247
Options that begin with
249
specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See
250
Section\ 5.5.7.3, \(lqSSL Command Options\(rq.
253
\fB\-\-user=\fR\fB\fIuser_name\fR\fR,
254
\fB\-u \fR\fB\fIuser_name\fR\fR
256
The MySQL user name to use when connecting to the server.
259
\fB\-\-use\-threads=\fR\fB\fIN\fR\fR
261
Load files in parallel using
269
Verbose mode. Print more information about what the program does.
275
Display version information and exit.
279
Here is a sample session that demonstrates use of
284
shell> \fBmysql \-e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test\fR
293
shell> \fBod \-c imptest.txt\fR
294
0000000 1 0 0 \\t M a x S y d o w \\n 1 0
295
0000020 1 \\t C o u n t D r a c u l a \\n
297
shell> \fBmysqlimport \-\-local test imptest.txt\fR
298
test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
299
shell> \fBmysql \-e 'SELECT * FROM imptest' test\fR
300
+\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
302
+\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
304
| 101 | Count Dracula |
305
+\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+
310
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
312
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.
314
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.
316
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/.
318
For more information, please refer to the MySQL Reference Manual,
319
which may already be installed locally and which is also available
320
online at http://dev.mysql.com/doc/.
322
Sun Microsystems, Inc. (http://www.mysql.com/).