mysqldude
Error codes › 3948

MySQL error 3948: Loading local data is disabled; this must be enabled on both the client and server sides

Error messageLoading local data is disabled; this must be enabled on both the client and server sides
Example from our test runs: 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.

SymbolER_CLIENT_LOCAL_FILES_DISABLED
SQLSTATE42000
TypeServer error
Versionssince 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_infile to OFF. 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 add local_infile = 1 under [mysqld] in my.cnf to keep it after a restart.
  • Client: mysql --local-infile=1 …. Drivers have their own switch, such as allowLoadLocalInfile=true for Connector/J, PDO::MYSQL_ATTR_LOCAL_INFILE for PHP, or local_infile=True for PyMySQL.
  • Or avoid LOCAL: copy the file into the server’s secure_file_priv directory and use LOAD DATA INFILE without LOCAL.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database and the test data:

    CREATE DATABASE demo;
    USE demo;
    CREATE TABLE t (a INT);
  2. Make a small CSV file on the client machine.

    printf '1\n2\n' > /tmp/data.csv
  3. As an admin, switch local loading off on the server (already the default on MySQL 8.0+).

    SET GLOBAL local_infile = 0;
  4. 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

  1. 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

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.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
✓✓✓✓✓✓✓✓✓
LOAD DATA LOCAL INFILE while the server has local_infile OFF (the MySQL 8.0+ default) repro
MySQL 5.6✓ 11485.7✓ 11488.0✓ 39488.4✓ 39489✓ 3948
MariaDB 10.6✓ 416610.11✓ 416611.4✓ 416611.8✓ 4166
The same statement with each server's default local_infile setting version check
MySQL 5.6✓5.7✓8.0✗ 39488.4✗ 39489✗ 3948
MariaDB 10.6✓10.11✓11.4✓11.8✓
Server allows it, but the client has local-infile disabled version check
MySQL 5.6✓ 11485.7✓ 11488.0✓ 20688.4✓ 20689✓ 2068
MariaDB 10.6✓ 416610.11✓ 416611.4✓ 416611.8✓ 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
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
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

  • 2068 CR_LOAD_DATA_LOCAL_INFILE_REJECTED
  • 1148 ER_NOT_ALLOWED_COMMAND
  • 1290 ER_OPTION_PREVENTS_STATEMENTexplained

Where this error shows up in our guides