I am using MySQL version 5.5 and I am trying to use load data infile and I am getting errors. I've looked at the documentation and it looks like I am doing exactly what the docs specify.
Running this command in mysql
LOAD DATA local infile '/home/pi/Downloads/load_data_infile.txt'
INTO TABLE test_tbl FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Gives the following error.
ERROR 1148 (42000): The used command is not allowed with this MySQL version
Running the following command
LOAD DATA local-infile '/home/pi/Downloads/load_data_infile.txt'
INTO TABLE test_tbl FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
Gives the following error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-infile '/home/pi/Downloads/load_data_infile.txt' INTO TABLE test_tbl FIELDS TER' at line 1
What is wrong with my syntax?
The data in the file is
126,126text,moretext
127,127text,moretext
Best Answer
CLIENT SIDE
Before you run this
You need to start mysql client program with
--local-file
If you wish to have this configured permanantly, add this to
~/.my.cnf
This forces the mysql client program to execute.
SERVER SIDE
The mysqld (server side must be started with local_infile) in its
my.cnf
ormy.ini
.Make sure to add this
and run
If you cannot config it and restart it, login to mysql and run
or
If you get
0
, you cannot executeLOAD DATA LOCAL INFILE
no matter what you do to the client side.SUPPLEMENTAL INFO
Running the following command
Gives the following error
That's just a straight up syntax error.
Get rid of the dash between
local
andinfile
so that it reads