Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 46.1Mb
PDF (A4) - 46.1Mb
PDF (RPM) - 41.5Mb
HTML Download (TGZ) - 10.6Mb
HTML Download (Zip) - 10.6Mb
HTML Download (RPM) - 9.1Mb
Man Pages (TGZ) - 220.4Kb
Man Pages (Zip) - 325.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
Excerpts from this Manual

MySQL 8.0 Reference Manual  /  ...  /  mysqlimport — A Data Import Program

4.5.5 mysqlimport — A Data Import Program

The mysqlimport client provides a command-line interface to the LOAD DATA SQL statement. Most options to mysqlimport correspond directly to clauses of LOAD DATA syntax. See Section 13.2.7, “LOAD DATA Syntax”.

Invoke mysqlimport like this:

shell> mysqlimport [options] db_name textfile1 [textfile2 ...]

For each text file named on the command line, mysqlimport 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 patient.txt, patient.text, and patient all would be imported into a table named patient.

mysqlimport supports the following options, which can be specified on the command line or in the [mysqlimport] and [client] groups of an option file. For information about option files used by MySQL programs, see Section 4.2.2.2, “Using Option Files”.

Table 4.14 mysqlimport Options

Option Name Description Introduced Removed
--bind-address Use specified network interface to connect to MySQL Server
--columns This option takes a comma-separated list of column names as its value
--compress Compress all information sent between client and server
--debug Write debugging log
--debug-check Print debugging information when program exits
--debug-info Print debugging information, memory, and CPU statistics when program exits
--default-auth Authentication plugin to use
--default-character-set Specify default character set
--defaults-extra-file Read named option file in addition to usual option files
--defaults-file Read only named option file
--defaults-group-suffix Option group suffix value
--delete Empty the table before importing the text file
--enable-cleartext-plugin Enable cleartext authentication plugin
--fields-enclosed-by This option has the same meaning as the corresponding clause for LOAD DATA
--fields-escaped-by This option has the same meaning as the corresponding clause for LOAD DATA
--fields-optionally-enclosed-by This option has the same meaning as the corresponding clause for LOAD DATA
--fields-terminated-by This option has the same meaning as the corresponding clause for LOAD DATA
--force Continue even if an SQL error occurs
--get-server-public-key Request RSA public key from server 8.0.3
--help Display help message and exit
--host Connect to MySQL server on given host
--ignore See the description for the --replace option
--ignore-lines Ignore the first N lines of the data file
--lines-terminated-by This option has the same meaning as the corresponding clause for LOAD DATA
--local Read input files locally from the client host
--lock-tables Lock all tables for writing before processing any text files
--login-path Read login path options from .mylogin.cnf
--low-priority Use LOW_PRIORITY when loading the table.
--no-defaults Read no option files
--password Password to use when connecting to server
--pipe Connect to server using named pipe (Windows only)
--plugin-dir Directory where plugins are installed
--port TCP/IP port number for connection
--print-defaults Print default options
--protocol Connection protocol to use
--replace The --replace and --ignore options control handling of input rows that duplicate existing rows on unique key values
--secure-auth Do not send passwords to server in old (pre-4.1) format 8.0.3
--server-public-key-path Path name to file containing RSA public key 8.0.4
--shared-memory-base-name Name of shared memory to use for shared-memory connections
--silent Produce output only when errors occur
--socket The Unix socket file or Windows named pipe to use
--ssl-ca File that contains list of trusted SSL Certificate Authorities
--ssl-capath Directory that contains trusted SSL Certificate Authority certificate files
--ssl-cert File that contains X.509 certificate
--ssl-cipher Permissible ciphers for connection encryption
--ssl-crl File that contains certificate revocation lists
--ssl-crlpath Directory that contains certificate revocation-list files
--ssl-fips-mode Whether to enable FIPS mode on client side 8.0.11
--ssl-key File that contains X.509 key
--ssl-mode Desired security state of connection to server
--tls-ciphersuites Permissible TLSv1.3 ciphersuites for encrypted connections 8.0.16
--tls-version Permissible TLS protocols for encrypted connections
--use-threads Number of threads for parallel file-loading
--user MySQL user name to use when connecting to server
--verbose Verbose mode
--version Display version information and exit

Here is a sample session that demonstrates use of mysqlimport:

shell> mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
shell> ed
a
100     Max Sydow
101     Count Dracula
.
w imptest.txt
32
q
shell> od -c imptest.txt
0000000   1   0   0  \t   M   a   x       S   y   d   o   w  \n   1   0
0000020   1  \t   C   o   u   n   t       D   r   a   c   u   l   a  \n
0000040
shell> mysqlimport --local test imptest.txt
test.imptest: Records: 2  Deleted: 0  Skipped: 0  Warnings: 0
shell> mysql -e 'SELECT * FROM imptest' test
+------+---------------+
| id   | n             |
+------+---------------+
|  100 | Max Sydow     |
|  101 | Count Dracula |
+------+---------------+