I am trying to load data into mysql database using
LOAD DATA LOCAL
INFILE A.txt
INTO DB
LINES TERMINATED BY '|';
the topic of this question is the response I get. I understand the local data offloading is off by default and I have to enable it using a the command local-infile=1
but I do not know where to place this command.
You can specify that as an additional option when setting up your client connection:
mysql -u myuser -p --local-infile somedatabase
This is because that feature opens a security hole. So you have to enable it in an explicit manner in case you really want to use it.
Both client and server should enable the local-file option. Otherwise it doesn't work.To enable it for files on the server side server add following to the my.cnf
configuration file:
loose-local-infile = 1
http://dev.mysql.com/doc/refman/5.6/en/load-data-local.html
Put this in my.cnf - the [client]
section should already be there
(if you're not too concerned about security).
[client]
loose-local-infile=1
I find the answer here.
It's because the server variable local_infile
is set to FALSE|0. Refer from the document.
You can verify by executing:
SHOW VARIABLES LIKE 'local_infile';
If you have SUPER privilege you can enable it (without restarting server with a new configuration) by executing:
SET GLOBAL local_infile = 1;
All of this didn't solve it for me on my brand new Ubuntu 15.04.
I removed the LOCAL
and got this command:
LOAD DATA
INFILE A.txt
INTO DB
LINES TERMINATED BY '|';
but then I got:
MySQL said: File 'A.txt' not found (Errcode: 13 - Permission denied)
That led me to this answer from Nelson to another question on stackoverflow which solved the issue for me!