Error
Error Code:
3948
MySQL Error 3948: Local Data Loading Disabled
Description
This error indicates that MySQL is preventing a client from loading data from a local file system into the database. It occurs when the `LOCAL_INFILE` capability, required for operations like `LOAD DATA LOCAL INFILE`, is not explicitly enabled on both the MySQL client application and the MySQL server instance. This is typically a security-related setting.
Error Message
Loading local data is disabled; this must be enabled on both the client and server sides
Known Causes
4 known causesServer `local_infile` Variable Disabled
The `local_infile` system variable on the MySQL server is set to `OFF`, preventing the server from accepting local file loads.
Client Does Not Request Local Infile
The client application or connection library is not configured to explicitly request or allow the `LOCAL_INFILE` capability when connecting to the MySQL server.
Mismatched Client and Server Settings
Even if one side is enabled, if the other side (client or server) explicitly disables or does not enable `LOCAL_INFILE`, this error will occur.
Organizational Security Policy
Corporate or organizational security policies might mandate disabling `LOCAL_INFILE` to prevent potential data exfiltration or unauthorized file access.
Solutions
3 solutions available1. Enable LOCAL INFILE on the Client easy
Configure your MySQL client to allow LOCAL INFILE operations.
1
When connecting to MySQL, use the `--local-infile=1` option.
mysql --local-infile=1 -u your_username -p your_database_name
2
If you are using a programming language connector (e.g., Python, Node.js), ensure you pass the appropriate parameter to enable local infile. For example, in Python with `mysql.connector`:
import mysql.connector
cnx = mysql.connector.connect(
user='your_username',
password='your_password',
host='your_host',
database='your_database_name',
allow_local_infile=True
)
3
For other languages, consult their respective MySQL connector documentation for the equivalent option (often named `local_infile`, `enable_local_infile`, or similar).
2. Enable LOCAL INFILE on the MySQL Server (Temporary) easy
Temporarily enable LOCAL INFILE for the current MySQL server session.
1
Connect to your MySQL server as a user with sufficient privileges (e.g., root).
2
Execute the following SQL command to enable the `local_infile` system variable for the current session.
SET GLOBAL local_infile = 1;
3
This change will be lost when the MySQL server restarts. For a permanent solution, see the next method.
3. Enable LOCAL INFILE on the MySQL Server (Permanent) medium
Permanently configure the MySQL server to allow LOCAL INFILE operations.
1
Locate your MySQL configuration file. This is typically `my.cnf` or `my.ini` and is often found in `/etc/mysql/`, `/etc/`, or within the MySQL installation directory.
2
Open the configuration file with a text editor (e.g., `nano`, `vim`).
3
Under the `[mysqld]` section, add or modify the following line:
[mysqld]
local-infile=1
4
Save the configuration file.
5
Restart the MySQL server for the changes to take effect.
sudo systemctl restart mysql # For systemd-based systems
# or
sudo service mysql restart # For SysVinit-based systems
6
After restarting, verify that `local_infile` is enabled by connecting to MySQL and running `SHOW GLOBAL VARIABLES LIKE 'local_infile';`.
SHOW GLOBAL VARIABLES LIKE 'local_infile';