Common SQL Errors

MySQL Error 2068: CR_LOAD_DATA_LOCAL_INFILE_REJECTED - How to Fix and Prevent

Galaxy Team
August 5, 2025

MySQL blocks a LOAD DATA LOCAL INFILE request because local file loading has been disabled on either the server or client.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 2068 (CR_LOAD_DATA_LOCAL_INFILE_REJECTED)?

MySQL Error 2068: CR_LOAD_DATA_LOCAL_INFILE_REJECTED means the server rejected LOAD DATA LOCAL INFILE because LOCAL loading is disabled. Re-enable it by starting the client with --local-infile or setting local_infile=1 on the server, then rerun the import.

Error Highlights

Typical Error Message

LOAD DATA LOCAL INFILE file request rejected due to restrictions on access. CR_LOAD_DATA_LOCAL_INFILE_REJECTED was added in 8.0.21.

Error Type

Client Error

Language

MySQL

Symbol

CR_LOAD_DATA_LOCAL_INFILE_REJECTED

Error Code

2068

SQL State

Explanation

Table of Contents

What is MySQL Error 2068 (CR_LOAD_DATA_LOCAL_INFILE_REJECTED)?

Error 2068 appears when a client issues LOAD DATA LOCAL INFILE and the server refuses the request. MySQL returns the message: “LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.” The error was introduced in MySQL 8.0.21 and is classified as a client-side error.

The keyword LOCAL instructs the client to read data from its own file system and stream it to the server. Administrators often disable this feature for security.

If either the client library or the server has LOCAL loading turned off, the request fails immediately with code 2068.

What Causes This Error?

Most occurrences trace back to the server system variable local_infile being set to OFF. When OFF, the server rejects every LOCAL file load regardless of client flags, returning CR_LOAD_DATA_LOCAL_INFILE_REJECTED.

The client program itself can also block LOCAL loading.

MySQL Shell, mysql CLI, and some connectors disable LOCAL unless you start them with the --local-infile option or set MYSQL_OPT_LOCAL_INFILE at runtime.

How to Fix MySQL Error 2068

First, verify whether the server allows LOCAL loading: SELECT @@GLOBAL.local_infile;. If it returns 0, enable it with SET GLOBAL local_infile = 1; then restart or reconnect so the change takes effect.

Next, confirm the client is launched with --local-infile or equivalent connector flag.

When server changes are impossible, remove LOCAL from the statement and place the file on a directory accessible to the server. Then use LOAD DATA INFILE '/var/lib/mysql-files/data.csv' instead, granting the FILE privilege if needed.

Common Scenarios and Solutions

Shared hosting environments force local_infile to OFF. In that case, upload the file to a secure directory on the server and switch to non-LOCAL import.

CI pipelines often use the mysql client without --local-infile.

Add mysql --local-infile -h${HOST} -u${USER} -p${PASS} < script.sql to enable imports in automated jobs.

Best Practices to Avoid This Error

Keep LOCAL loading disabled in production and enable it only for trusted users on development machines. Rotate credentials and limit FILE privileges to reduce risk of arbitrary file reads.

Galaxy users can save approved import scripts in a Collection and run them from the fast local editor.

Galaxy maintains execution history, making it easy to audit who enabled LOCAL and when.

Related Errors and Solutions

Server error 1148 (42000) “The used command is not allowed with this MySQL version” also fires when local_infile is OFF, but it appears on the server side. The fix is identical: turn on local_infile or drop LOCAL.

Error 1045 (28000) “Access denied for user” surfaces when the session lacks FILE privilege. Grant FILE on *.* to user@host; resolves it.

.

Common Causes

Related Errors

FAQs

Is enabling local_infile safe in production?

Enable it only for trusted users and consider a read-only server directory. Disable it globally once the import is complete.

Do I need FILE privilege for LOAD DATA LOCAL INFILE?

No. FILE privilege is needed only for non-LOCAL imports. LOCAL imports run solely with client file read permissions.

Why does Error 2068 appear after upgrading to 8.0.21?

MySQL introduced a clearer client-side code for this scenario. Your previous setup already blocked LOCAL loads, but the server now uses 2068 to indicate it.

How does Galaxy help avoid this error?

Galaxy surfaces server variables, warns when local_infile is OFF, and lets you share corrected scripts so teammates avoid 2068.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo