MySQL - Loading a text file into ue table

Ask a question

  • 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);

Avoid being blocked in case of the error :TOO MANY CONNECTIONS
MySQL - Linux Monitoring port 3306