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 questi
Refer to MySQL 8.0 Reference Manual -- 6.1.6 Security Issues with LOAD DATA LOCAL
On the server side, run
mysql.server start --local-infile
On the client side, run
mysql --local-infile database_name -u username -p
Just little addition.
Found another reincarnation in mysql.connector ver 8.0.16 It now requires allow_local_infile=True or you will see the above error. Worked in prior versions.
conn = mysql.connector.connect(host=host, user=user, passwd=passwd, database=database, allow_local_infile=True)
If you are using Java8 or + version, JDBC and MySql8 and facing this issue then try this:
Add parameter to connection string:
jdbc:mysql://localhost:3306/tempDB?allowLoadLocalInfile=true
Also, set
local_infile = 1
in my.cnf file.
The latest version of mysql-java-connector might be wont allow directly to connect to local file. So with this parameter, you can able to enable it. This works for me.
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
The top answers are correct. Please check them direct in MySQL CLI first. If this fixes the problem there, you may want to have it working in Python3 just pass it to the MySQLdb.connect
as parameter
self.connection = MySQLdb.connect(
host=host, user=settings_DB.db_config['USER'],
port=port, passwd=settings_DB.db_config['PASSWORD'],
db=settings_DB.db_config['NAME'],
local_infile=True)
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