MySQL - Loading a text file into ue table

October 2016

  • To load a text file, perform as follow:

$ tail /home/user1/test.txt 
  • In a table defined as follows:

CREATE TABLE chargertest ( 
                prim_key int(11) NOT NULL auto_increment, 
                name varchar(20), 
                x integer, 
                y integer, 
                z timestamp(14), 
                Constraint pk_chargertest PRIMARY KEY  (prim_key) 
  • Note that the 'z' is not defined in the text file and the separator is','.

mysql> load data infile '/home/user1/test.txt' into table chargertest fields terminated by ',' (name,x,y);

Related :

This document entitled « MySQL - Loading a text file into ue table » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.