mysqlimport - A MySQL Data Import Program

MySQLMySQLi Database

The mysqlimport client comes with a command-line interface that helps with the LOAD DATA SQL statement. Most options to mysqlimport respond directly to clauses of LOAD DATA syntax

Invoking mysqlimport

The utility mysqlimport can be invoked as shown below −

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

For every text file that is named on the command line, mysqlimport strips any extension from the file name and uses the result to figure out the name of the table into which the file's contents have to be imported.

Example

Let us take an example: Files named sample.txt, sample.text, and sample all would be imported into a table named sample.

This utlity supports the following options, which can be specified on the command line or in the [mysqlimport] and [client] groups of an option file.

--bind-address=ip_address

If the computer has multiple network interfaces, this option can be used to select which interface needs to be used to connect to the MySQL server.

--character-sets-dir=dir_name

It is the directory where character sets are installed.

--columns=column_list, -c column_list

It takes a list of comma-separated column names as its value. The order of the column names indicate how data file columns have to be matched with the table columns.

--compress, -C

It compresses all information sent between the client and the server if possible.

--compression-algorithms=value

It refers to the permitted compression algorithms for connections to the server. The available algorithms are the same as that for the protocol_compression_algorithms system variable. The default value is uncompressed.

--enable-cleartext-plugin

It enables the mysql_clear_password cleartext authentication plugin.

--force, -f

This option ignores the errors. Let us take an example: If a table for a text file does not exist, continue processing the remaining files. Without --force, mysqlimport exits if a table does not exist.

raja
Published on 10-Mar-2021 13:02:26
Advertisements