secure_file_priv 和 mysqlimport

secure_file_priv and mysqlimport

问题:当数据文件在当前目录下时,mysqlimport如何避免以下类型的错误?

mysqlimport: Error: 13, Can't get stat of '/var/lib/mysql/«dbname»/«tablename».txt' (OS errno 2 - No such file or directory), when using table: «tablename»

我们正在使用 MySQL 版本 8.0.28


背景:

我们的问题从 LOAD DATA INFILE 开始,出现以下错误:

The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

此问题已按照 https://computingforgeeks.com/how-to-solve-mysql-server-is-running-with-the-secure-file-priv-error/

中的提示解决

基本上我们编辑了 MySQL 选项文件来设置 secure‐file‐priv = ""
此外,我们确保文件的所有者和组设置为 mysql.

有了这些变化 LOAD DATA INFILE 就像一个魅力。但是,这些更改对 mysqlimport.

没有影响

mysqlimport 给出以下错误:

mysqlimport: Error: 13, Can't get stat of '/var/lib/mysql/«dbname»/«tablename».txt' (OS errno 2 - No such file or directory), when using table: «tablename»

我们能够通过首先为加载数据启用本地功能来解决问题

mysql> SET GLOBAL local_infile = TRUE;

之后我们开始使用 --local 选项调用 mysqlimport