簡體   English   中英

無法使用 MySQL LOAD DATA LOCAL infile 到遠程 MySQL 服務器

[英]Cannot use MySQL LOAD DATA LOCAL infile to remote MySQL server

目前,我們正在遷移 ColdFusion 2021 服務器環境。 舊環境搭建在CF2016和MySQL 5.7之上。 新環境為CF2021和MySQL 8.0.27。 另外,我們已經拆分了 CF 服務器和 MySQL 服務器,所以此時它們是 2 個不同的服務器。

我們在 CF 代碼中有一個 function,它創建 csv 文件(本地)並插入到 MySQL 服務器的表中。

查詢是這樣寫的:

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 數據源連接器使用名為“mysql-connector-java-8.0.22.jar”的 java 文件。

任何幫助將非常感激! 謝謝

[client]部分僅適用於 MySQL 命令行客戶端,例如mysqlmysqldumpmysqladmin 它不適用於其他客戶端接口、API 或連接器。 所以它不適用於 ColdFusion。

您需要使連接器啟用 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. 請參閱https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connp-props-security.ZFC35FDC70D5FC69D2698Z83A822C7A5E3

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM