简体   繁体   中英

Cannot use MySQL LOAD DATA LOCAL infile to remote MySQL server

Currently, we are in the process of migrating a ColdFusion 2021 server environment. The old environment was built on CF2016 and MySQL 5.7. The new environment is CF2021 and MySQL 8.0.27. Also, we have split the CF server and the MySQL server, so they are 2 different servers at this point.

We have a function in the CF code which creates csv files (locally) and inserts into a table of the MySQL server.

The query is written like this:

LOAD DATA LOCAL infile 'local-path-to-file' into table op_customer_call_records_work
fields terminated by '|'
lines terminated by '\n'
(master_id,map_id,host_id,,..etc..,cdr_source)

When this attempts to insert, I get this error:

Executing Database Query. (Loading local data is disabled; this must be enabled on both the client and server sides)

I have already set this in the my.cnf:

[client]  
loose-local-infile=1

[mysql]
local-infile=1

[mysqld]
local-infile=1
secure-file-priv = ""

and restarted the MySQL server.

My assumption is the [client] tag in the my.cnf file is either incorrect or being ignored. Also, the CF datasource connector uses a java file called: 'mysql-connector-java-8.0.22.jar' if that helps.

Any help would be much appreciated! thanks

The [client] section only applies to MySQL command-line clients like mysql , mysqldump , or mysqladmin . It does not apply to other client interfaces, APIs, or connectors. So it won't apply to ColdFusion.

You need to make the connector enable local-infile.

For example, if you use MySQL Connector/J to connect ColdFusion to MySQL Server, you would need to add the allowLoadLocalInfile option to the JDBC URL. See https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connp-props-security.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM