The LOAD DATA INFILE statement reads rows from a text file into a
table at a very high speed.
For more information about the efficiency of INSERT versus
LOAD DATA INFILE and speeding up LOAD DATA INFILE,
[Insert speed].

As of MySQL 4.1, the character set indicated by the
character_set_database system variable is used to interpret the
information in the file.  SET NAMES and the setting of
character_set_client do not affect input interpretation.

You can also load data files by using the mysqlimport utility; it
operates by sending a LOAD DATA INFILE statement to the server.  The
--local option causes mysqlimport to read data files from the
client host.  You can specify the --compress option to get better
performance over slow networks if the client and server support the
compressed protocol.
See also : [mysqlimport,  , mysqlimport].

If you specify the LOW_PRIORITY keyword, execution of the
LOAD DATA statement is delayed until no other clients are reading
from the table.

If you specify the CONCURRENT keyword with a MyISAM table that
satisfies the condition for concurrent inserts (that is, it contains no free
blocks in the middle),
then other threads can retrieve data from the table while LOAD DATA
is executing. Using this option affects the performance of LOAD DATA
a bit, even if no other thread is using the table at the same time.

If the LOCAL keyword is specified, it is
interpreted with respect to the client end of the connection:


 --- If LOCAL is specified, the file is read by the client program on the
client host and sent to the server. The file can be given as a full pathname
to specify its exact location. If given as a relative pathname, the name is
interpreted relative to the directory in which the client program was started.

 --- If LOCAL is not specified, the
file must be located on the server host and is read directly by the server.


LOCAL is available in MySQL 3.22.6 or later.

When locating files on the server host, the server uses the following rules:

 --- If an absolute pathname is given, the server uses the pathname as is.

 --- If a relative pathname with one or more leading components is given,
the server searches for the file relative to the server's data directory.

 --- If a filename with no leading components is given, the server looks for
the file in the database directory of the default database.

Note that these rules mean that a file named as *./myfile.txt is read from
the server's data directory, whereas the same file named as *myfile.txt is
read from the database directory of the default database.  For example,
the following LOAD DATA statement reads the file *data.txt
from the database directory for db1 because db1 is the current
database, even though the statement explicitly loads the file into a
table in the db2 database:

mysql> USE db1;
mysql> LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;

Note that Windows pathnames are specified using forward slashes rather than
backslashes.  If you do use backslashes, you must double them.

For security reasons, when reading text files located on the server, the
files must either reside in the database directory or be readable by all.
Also, to use LOAD DATA INFILE on server files, you must have the
FILE privilege.
