MySQL error 3948: Loading local data is disabled; this must be enabled on both the client and server sides
Loading local data is disabled; this must be enabled on both the client and server sides (8.0.46) LOAD DATA LOCAL INFILE is switched off on the server (local_infile=OFF, the MySQL 8.0 default). Enable it on the server and the client, or load a server-side file instead.
| Symbol | ER_CLIENT_LOCAL_FILES_DISABLED |
|---|---|
| SQLSTATE | 42000 |
| Type | Server error |
| Versions | since 8.0.20 active |
What it means
LOAD DATA LOCAL INFILE makes the client read a file and send it to the server. Because a malicious server could ask a client for any file, both sides have to allow it: the server with local_infile = ON, and the client with --local-infile=1 (or the driver’s equivalent option). 3948 means the server refused.
Why it happens
- MySQL 8.0 changed the default of
local_infiletoOFF. Import scripts that worked on 5.7 fail after an upgrade. - Tested: MySQL 5.6/5.7 report the refusal as 1148 “The used command is not allowed with this MySQL version”, and MariaDB 10.6–11.8 as 4166 “…the MariaDB server or client has disabled the local infile capability”. MariaDB and MySQL 5.x have local_infile ON by default.
- When the client side is disabled, MySQL 8.0+ clients report 2068 “LOAD DATA LOCAL INFILE file request rejected due to restrictions on access” instead.
How to fix it
- Server:
SET GLOBAL local_infile = 1;(needs an admin account) and addlocal_infile = 1under[mysqld]in my.cnf to keep it after a restart. - Client:
mysql --local-infile=1 …. Drivers have their own switch, such asallowLoadLocalInfile=truefor Connector/J,PDO::MYSQL_ATTR_LOCAL_INFILEfor PHP, orlocal_infile=Truefor PyMySQL. - Or avoid
LOCAL: copy the file into the server’ssecure_file_privdirectory and useLOAD DATA INFILEwithoutLOCAL.
Reproduce it yourself
These steps are the exact test our harness runs. Use a scratch server, never production.
Connect with
mysql -u root -pand create a scratch database and the test data:CREATE DATABASE demo; USE demo; CREATE TABLE t (a INT);Make a small CSV file on the client machine.
printf '1\n2\n' > /tmp/data.csvAs an admin, switch local loading off on the server (already the default on MySQL 8.0+).
SET GLOBAL local_infile = 0;Load the file with a client that allows it. The server refuses.
mysql --local-infile=1 -u root -p demo -e "LOAD DATA LOCAL INFILE '/tmp/data.csv' INTO TABLE t"
You get: ERROR 3948 (42000) at line 1: Loading local data is disabled; this must be enabled on both the client and server sides(9.7.4)
Verified fixes
Enable local_infile on the server and --local-infile=1 on the client (or load a server-side file from secure_file_priv)
On the server (and in my.cnf under [mysqld] to keep it):
SET GLOBAL local_infile = 1;On the client:
mysql --local-infile=1 -u root -p demo -e "LOAD DATA LOCAL INFILE '/tmp/data.csv' INTO TABLE t"
Tested on
| Step | MySQL | MariaDB | |||||||
|---|---|---|---|---|---|---|---|---|---|
| 5.6 | 5.7 | 8.0 | 8.4 | 9 | 10.6 | 10.11 | 11.4 | 11.8 | |
| LOAD DATA LOCAL INFILE while the server has local_infile OFF (the MySQL 8.0+ default) repro | ✓ 1148 | ✓ 1148 | ✓ 3948 | ✓ 3948 | ✓ 3948 | ✓ 4166 | ✓ 4166 | ✓ 4166 | ✓ 4166 |
| The same statement with each server's default local_infile setting version check | ✓ | ✓ | ✗ 3948 | ✗ 3948 | ✗ 3948 | ✓ | ✓ | ✓ | ✓ |
| Server allows it, but the client has local-infile disabled version check | ✓ 1148 | ✓ 1148 | ✓ 2068 | ✓ 2068 | ✓ 2068 | ✓ 4166 | ✓ 4166 | ✓ 4166 | ✓ 4166 |
| Enable local_infile on the server and --local-infile=1 on the client (or load a server-side file from secure_file_priv) fix | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
What the warnings and failures say (1)
- The same statement with each server's default local_infile setting (MySQL 8.0, MySQL 8.4, MySQL 9): error 3948: ERROR 3948 (42000) at line 1: Loading local data is disabled; this must be enabled on both the client and server sides
Related errors
Where this error shows up in our guides
- LOAD DATA INFILE with auto_increment · LOAD DATA LOCAL INFILE with server defaults MySQL 8.0 8.4 9