无法使用 MySQL LOAD DATA LOCAL infile 到远程 MySQL 服务器

Cannot use MySQL LOAD DATA LOCAL infile to remote MySQL server

目前,我们正在迁移 ColdFusion 2021 服务器环境。旧环境建立在CF2016和MySQL 5.7之上。新环境是CF2021和MySQL8.0.27。此外,我们已经拆分了 CF 服务器和 MySQL 服务器,因此此时它们是 2 个不同的服务器。

我们在 CF 代码中有一个函数,它创建 csv 文件(本地)并插入 MySQL 服务器的 table。

查询是这样写的:

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)

当它试图插入时,我得到这个错误:

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

我已经在my.cnf中设置了这个:

[client]  
loose-local-infile=1

[mysql]
local-infile=1

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

并重新启动了 MySQL 服务器。

我的假设是 my.cnf 文件中的 [client] 标签不正确或被忽略了。此外,CF 数据源连接器使用名为 java 的文件:'mysql-connector-java-8.0.22.jar' 如果有帮助。

如有任何帮助,我们将不胜感激! 谢谢

选项文件中的 [client] 部分仅适用于 MySQL 命令行客户端,例如 mysqlmysqldumpmysqladmin。它不适用于其他客户端接口、API 或连接器。所以它不适用于 ColdFusion。

您需要使连接器启用 local-infile。

例如,如果您使用 MySQL Connector/J 将 ColdFusion 连接到 MySQL 服务器,则需要将 allowLoadLocalInfile 选项添加到 JDBC URL。参见 https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connp-props-security.html