1MYSQLIMPORT(1) MySQL Database System MYSQLIMPORT(1)
2
3
4
6 mysqlimport - a data import program
7
9 mysqlimport [options] db_name textfile1 ...
10
12 The mysqlimport client provides a command-line interface to the LOAD
13 DATA INFILE SQL statement. Most options to mysqlimport correspond
14 directly to clauses of LOAD DATA INFILE syntax. See Section 12.2.6,
15 “LOAD DATA INFILE Syntax”.
16
17 Invoke mysqlimport like this:
18
19 shell> mysqlimport [options] db_name textfile1 [textfile2 ...]
20
21 For each text file named on the command line, mysqlimport strips any
22 extension from the file name and uses the result to determine the name
23 of the table into which to import the file´s contents. For example,
24 files named patient.txt, patient.text, and patient all would be
25 imported into a table named patient.
26
27 For additional information about mysqldump, see Section 6.4, “Using
28 mysqldump for Backups”.
29
30 mysqldump supports the following options, which can be specified on the
31 command line or in the [mysqldump] and [client] option file groups.
32 mysqldump also supports the options for processing option files
33 described at Section 4.2.3.3.1, “Command-Line Options that Affect
34 Option-File Handling”.
35
36 · --help, -?
37
38 Display a help message and exit.
39
40 · --character-sets-dir=path
41
42 The directory where character sets are installed. See Section 9.5,
43 “Character Set Configuration”.
44
45 · --columns=column_list, -c column_list
46
47 This option takes a comma-separated list of column names as its
48 value. The order of the column names indicates how to match data
49 file columns with table columns.
50
51 · --compress, -C
52
53 Compress all information sent between the client and the server if
54 both support compression.
55
56 · --debug[=debug_options], -# [debug_options]
57
58 Write a debugging log. A typical debug_options string is
59 ´d:t:o,file_name´. The default is ´d:t:o´.
60
61 · --debug-check
62
63 Print some debugging information when the program exits. This
64 option was added in MySQL 5.1.21.
65
66 · --debug-info
67
68 Print debugging information and memory and CPU usage statistics
69 when the program exits. This option was added in MySQL 5.1.14.
70
71 · --default-character-set=charset_name
72
73 Use charset_name as the default character set. See Section 9.5,
74 “Character Set Configuration”.
75
76 · --defaults-extra-file=filename
77
78 Set filename as the file to read default options from after the
79 global defaults files has been read. Must be given as first
80 option.
81
82 · --defaults-file=filename
83
84 Set filename as the file to read default options from, override
85 global defaults files. Must be given as first option.
86
87 · --delete, -d
88
89 Empty the table before importing the text file.
90
91 · --fields-terminated-by=..., --fields-enclosed-by=...,
92 --fields-optionally-enclosed-by=..., --fields-escaped-by=...
93
94 These options have the same meaning as the corresponding clauses
95 for LOAD DATA INFILE. See Section 12.2.6, “LOAD DATA INFILE
96 Syntax”.
97
98 · --force, -f
99
100 Ignore errors. For example, if a table for a text file does not
101 exist, continue processing any remaining files. Without --force,
102 mysqlimport exits if a table does not exist.
103
104 · --host=host_name, -h host_name
105
106 Import data to the MySQL server on the given host. The default host
107 is localhost.
108
109 · --ignore, -i
110
111 See the description for the --replace option.
112
113 · --ignore-lines=N
114
115 Ignore the first N lines of the data file.
116
117 · --lines-terminated-by=...
118
119 This option has the same meaning as the corresponding clause for
120 LOAD DATA INFILE. For example, to import Windows files that have
121 lines terminated with carriage return/linefeed pairs, use
122 --lines-terminated-by="\r\n". (You might have to double the
123 backslashes, depending on the escaping conventions of your command
124 interpreter.) See Section 12.2.6, “LOAD DATA INFILE Syntax”.
125
126 · --local, -L
127
128 Read input files locally from the client host.
129
130 · --lock-tables, -l
131
132 Lock all tables for writing before processing any text files. This
133 ensures that all tables are synchronized on the server.
134
135 · --low-priority
136
137 Use LOW_PRIORITY when loading the table. This affects only storage
138 engines that use only table-level locking (such as MyISAM, MEMORY,
139 and MERGE).
140
141 · --no-defaults
142
143 Do not read default options from any option file. This must be
144 given as the first argument.
145
146 · --password[=password], -p[password]
147
148 The password to use when connecting to the server. If you use the
149 short option form (-p), you cannot have a space between the option
150 and the password. If you omit the password value following the
151 --password or -p option on the command line, mysqlimport prompts
152 for one.
153
154 Specifying a password on the command line should be considered
155 insecure. See Section 5.3.2.2, “End-User Guidelines for Password
156 Security”. You can use an option file to avoid giving the password
157 on the command line.
158
159 · --pipe, -W
160
161 On Windows, connect to the server via a named pipe. This option
162 applies only if the server supports named-pipe connections.
163
164 · --port=port_num, -P port_num
165
166 The TCP/IP port number to use for the connection.
167
168 · --protocol={TCP|SOCKET|PIPE|MEMORY}
169
170 The connection protocol to use for connecting to the server. It is
171 useful when the other connection parameters normally would cause a
172 protocol to be used other than the one you want. For details on the
173 allowable values, see Section 4.2.2, “Connecting to the MySQL
174 Server”.
175
176 · --print-defaults
177
178 Print the program argument list and exit. This must be given as
179 the first argument.
180
181 · --replace, -r
182
183 The --replace and --ignore options control handling of input rows
184 that duplicate existing rows on unique key values. If you specify
185 --replace, new rows replace existing rows that have the same unique
186 key value. If you specify --ignore, input rows that duplicate an
187 existing row on a unique key value are skipped. If you do not
188 specify either option, an error occurs when a duplicate key value
189 is found, and the rest of the text file is ignored.
190
191 · --silent, -s
192
193 Silent mode. Produce output only when errors occur.
194
195 · --socket=path, -S path
196
197 For connections to localhost, the Unix socket file to use, or, on
198 Windows, the name of the named pipe to use.
199
200 · --ssl*
201
202 Options that begin with --ssl specify whether to connect to the
203 server via SSL and indicate where to find SSL keys and
204 certificates. See Section 5.5.6.3, “SSL Command Options”.
205
206 · --user=user_name, -u user_name
207
208 The MySQL user name to use when connecting to the server.
209
210 · --use-threads=N
211
212 Load files in parallel using N threads. This option was added in
213 MySQL 5.1.7.
214
215 · --verbose, -v
216
217 Verbose mode. Print more information about what the program does.
218
219 · --version, -V
220
221 Display version information and exit.
222
223 Here is a sample session that demonstrates use of mysqlimport:
224
225 shell> mysql -e ´CREATE TABLE imptest(id INT, n VARCHAR(30))´ test
226 shell> ed
227 a
228 100 Max Sydow
229 101 Count Dracula
230 .
231 w imptest.txt
232 32
233 q
234 shell> od -c imptest.txt
235 0000000 1 0 0 \t M a x S y d o w \n 1 0
236 0000020 1 \t C o u n t D r a c u l a \n
237 0000040
238 shell> mysqlimport --local test imptest.txt
239 test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
240 shell> mysql -e ´SELECT * FROM imptest´ test
241 +------+---------------+
242 | id | n |
243 +------+---------------+
244 | 100 | Max Sydow |
245 | 101 | Count Dracula |
246 +------+---------------+
247
249 Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
250
251 This documentation is free software; you can redistribute it and/or
252 modify it only under the terms of the GNU General Public License as
253 published by the Free Software Foundation; version 2 of the License.
254
255 This documentation is distributed in the hope that it will be useful,
256 but WITHOUT ANY WARRANTY; without even the implied warranty of
257 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
258 General Public License for more details.
259
260 You should have received a copy of the GNU General Public License along
261 with the program; if not, write to the Free Software Foundation, Inc.,
262 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
263 http://www.gnu.org/licenses/.
264
265
267 For more information, please refer to the MySQL Reference Manual, which
268 may already be installed locally and which is also available online at
269 http://dev.mysql.com/doc/.
270
272 Sun Microsystems, Inc. (http://www.mysql.com/).
273
274
275
276MySQL 5.1 04/06/2010 MYSQLIMPORT(1)