Error 2068: the client rejected your LOAD DATA LOCAL INFILE file
ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.Short answer
Error 2068 is raised by the client library. Local loading is switched off there, and the only exception is the directory set with --load-data-local-dir (or MYSQL_OPT_LOAD_DATA_LOCAL_DIR). A file outside that directory, an empty directory value, or a path that differs in letter case is turned away. Enable local loading or use the right path.
Fix it fast
1Find out which cause you have
Find out how the client was started. Look for --local-infile and --load-data-local-dir in the command, in the option files, or in the program's connection settings.
grep -R -n -E "local-infile|load-data-local-dir" ~/.my.cnf /etc/my.cnf /etc/mysql/ 2>/dev/null2Match what you see, then jump to its fix
- 1
The client runs with --local-infile=0, a library default of off, or --load-data-local-dir pointing somewhere else.Local loading is off and the file is outside the permitted directoryFix - 2
--load-data-local-dir is set and the file looks like it is inside, for example /Data versus /data.The file path differs from the permitted directory in letter caseFix
- 1
What does the error look like?
ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.
Cause 1 of 2
Local loading is off and the file is outside the permitted directory
1Check
When LOCAL loading is disabled, --load-data-local-dir names the one directory local files may come from. Left empty (the default), it names no directory, so no file is permitted. If LOCAL loading is enabled, the option is ignored.
grep -R -n -E "local-infile|load-data-local-dir" ~/.my.cnf /etc/my.cnf /etc/mysql/ 2>/dev/null2Fix
Either move the file into the permitted directory, or start the client with local loading enabled. The server must allow it too.
mysql --local-infile=1 -u app -p mydb
-- on the server, if the variable is OFF:
SET GLOBAL local_infile = 1;3Verify
Run the same LOAD DATA LOCAL INFILE statement again.
LOAD DATA LOCAL INFILE '/home/me/data/users.csv' INTO TABLE users FIELDS TERMINATED BY ',';Confirmed by dev.mysql.com
Cause 2 of 2
The file path differs from the permitted directory in letter case
1Check
The directory path and the file path are compared case-sensitively, whatever the file system's own rules are. On a case-insensitive disk the file opens in the shell but the comparison still fails.
grep -R -n "load-data-local-dir" ~/.my.cnf /etc/my.cnf /etc/mysql/ 2>/dev/null2Fix
Write the file path with exactly the same letters as the directory in the option.
mysql --local-infile=0 --load-data-local-dir=/my/local/data -u app -p mydb
-- then load /my/local/data/users.csv, not /My/Local/Data/users.csv3Verify
The statement completes and reports the rows loaded.
SELECT COUNT(*) FROM users;Confirmed by dev.mysql.com
How do I stop it coming back?
- Prefer a restricted directory (--load-data-local-dir) over enabling LOCAL for everything.
- Keep import files in one fixed folder and quote the same path in scripts.
- Remember that the server also has to allow LOCAL loading, or error 3950 follows.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
LOAD DATA LOCAL INFILE is refused: loading local data is disabled
ERROR 3950 (42000): Loading local data is disabled; this must be enabled on both the client and server side
LOAD DATA LOCAL works only when both the server and the client allow it.
3 causes, each with a fixDatabases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fix