我应该如何处理 MySQL 中的 --secure-file-priv?

2021-11-20 00:00:00 database mysql

我正在学习 MySQL 并尝试使用 LOAD DATA 子句.当我使用它时:

I am learning MySQL and tried using a LOAD DATA clause. When I used it as below:

LOAD DATA INFILE "text.txt" INTO table mytable;

我收到以下错误:

MySQL 服务器正在使用 --secure-file-priv 选项运行,因此它无法执行此语句

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

我该如何解决这个错误?

How do I tackle this error?

我已经检查了 关于同一错误消息的另一个问题,但仍然找不到解决方案.

I have checked another question on the same error message, but still can’t find a solution.

我使用的是 MySQL 5.6

I am using MySQL 5.6

推荐答案

它按预期工作.您的 MySQL 服务器已启动 --secure-file-priv 选项基本上限制了您可以使用 LOAD DATA INFILE 从哪些目录加载文件.

It's working as intended. Your MySQL server has been started with --secure-file-priv option which basically limits from which directories you can load files using LOAD DATA INFILE.

您可以使用 SHOW VARIABLES LIKE "secure_file_priv"; 查看已配置的目录.

You may use SHOW VARIABLES LIKE "secure_file_priv"; to see the directory that has been configured.

您有两个选择:

  1. 将您的文件移动到 secure-file-priv 指定的目录.
  2. 禁用secure-file-priv.这必须从启动中删除,不能动态修改.为此,请检查您的 MySQL 启动参数(取决于平台)和 my.ini.
  1. Move your file to the directory specified by secure-file-priv.
  2. Disable secure-file-priv. This must be removed from startup and cannot be modified dynamically. To do this check your MySQL start up parameters (depending on platform) and my.ini.

相关文章