mysql imports txt file data through load data local infile

If you need to insert a large amount of data at one time, use the insert statement to insert low performance

Data insertion can be performed using the instructions provided by the MySQL database load :

# 执行load指令将准备好的数据,加载到表结构中
load data local infile '/root/data.txt' --注意文件地址要输入正确
into table `tb_user`        --需要导入的表名
fields terminated by ','    --指定文件的每个字段用 , 分隔
optionally enclosed by '"'  --数据源的字段开始和结束都是带双引号的,无视这些个双引号
escaped by ' '              --空格字符将被去除
lines terminated by '\n';   --以回车字符结束

txt file data like this:

 

Execute load data local infile if an error is found: Loading local data is disabled; this must be enabled on both the client and server sides 

Translation: forLoading local data is disabled; this must be enabled on both the client and server

This kind of error is a mysql import data error: the local_infile server variable indicates whether the load data local infile command can be used. When this variable is OFF, the load data local infile command of the client is disabled. As long as we set this variable to ON, the error will disappear.


Solution:

Enter the command in mysql: set global local_infile=1;

Guess you like

Origin blog.csdn.net/lwpoor123/article/details/127508368