I'm running Mysql 5.5 on Ubuntu 12 LTS. How should I enable LOAD DATA LOCAL INFILE in my.cnf?
I've tried adding local-infile in my config at various places but I'm still getting the "The used command is not allowed with this MySQL version"
I'm running Mysql 5.5 on Ubuntu 12 LTS. How should I enable LOAD DATA LOCAL INFILE in my.cnf?
I've tried adding local-infile in my config at various places but I'm still getting the "The used command is not allowed with this MySQL version"
In case if Mysql 5.7 you can use "show global variables like "local_infile" ;" which will give the local infile status ,You can turn it on using "set global local_infile=ON ; ".
See below image...
I've added
--local-infile=1
to normal mysql commandmysql -u root -p
So total line would be :
From the MySQL 5.5 manual page:
You should set the option:
into your [mysql] entry of my.cnf file or call mysql client with the --local-infile option:
You have to be sure that the same parameter is defined into your [mysqld] section too to enable the "local infile" feature server side.
It's a security restriction.
Also, for other readers, if you are trying to do this in Django AND your server allows local_infile (you can check by typing SHOW VARIABLES via a mysql client) then you can add this to your settings.py file (since python MySQLdb doesn't by default read the .my.cnf file):
if your csv file located same with db, you need to remove LOCAL in LOAD DATA INFILE, or you will get the error
You have to take care how you establish your mysqli connection. Full credit for this solution goes to Jorge Albarenque, source
In order to fix it I had to:
The catch is that with that function you can explicitly enable the support for LOAD DATA LOCAL INFILE. For example (procedural style):
or object oriented