You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LOAD DATA LOCAL INFILE报2068错误排查(已开启local_infile)

Troubleshooting "LOAD DATA LOCAL INFILE Access Restriction" Error

Hey there, let's work through this frustrating access error you're getting with LOAD DATA LOCAL INFILE. You've already checked that local_infile is set to ON, which is a great first step—let's dive into the other common fixes that usually resolve this issue:

1. Ensure Your Client Enables Local INFILE Support

Most MySQL clients don't enable local file loading by default, even if the server has local_infile=ON:

  • Command Line: When connecting, add the --local-infile=1 flag:
    mysql --user=your_username --password=your_password --local-infile=1 your_database_name
    
  • MySQL Workbench: Go to your connection settings, under the "Advanced" tab, find and check the Enable local INFILE option, then reconnect.
  • Other Clients: Look for a setting labeled "Allow local file imports" or similar in your client's configuration.

2. Fix Windows File Path Escaping

On Windows, backslashes (\) in file paths need to be escaped (doubled) or replaced with forward slashes (/), since MySQL interprets single backslashes as escape characters. Your path should look like one of these:

LOAD DATA LOCAL INFILE 'C:\\Users\\amanda.ramos\\Desktop\\EdX_Enrollment.csv' INTO TABLE records
-- OR
LOAD DATA LOCAL INFILE 'C:/Users/amanda.ramos/Desktop/EdX_Enrollment.csv' INTO TABLE records

3. Verify File Permissions for the MySQL Service

The user account running the MySQL service needs read access to your CSV file:

  1. Right-click the EdX_Enrollment.csv file → Properties → Security tab.
  2. Click Edit → Add to include the MySQL service user (often Local System or a dedicated MySQL user).
  3. Grant the user Read permissions and save changes.

4. Check Both Server and Client Configuration in my.ini/my.cnf

Even if SHOW GLOBAL VARIABLES LIKE 'local_infile' returns ON, make sure your MySQL config file (my.ini on Windows, my.cnf on Linux) enables local infile for both server and client sections:

[mysqld]
local_infile=ON

[client]
local_infile=ON

After making changes, restart the MySQL service to apply them.

5. Rule Out Firewall/Antivirus Interception

Some security tools block MySQL from accessing local files. Temporarily disable your antivirus or firewall (just for testing) to see if that resolves the issue. If it does, add MySQL to your security tool's trusted applications list.

Start with checking the client setting and path escaping first—those are the most frequent causes of this error. Let me know if any of these steps get you past the restriction!

内容的提问来源于stack exchange,提问作者Amanda Ramos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 16:07:38