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

An error is reported when MySQL uses a file to import data:

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

Interim solution:

Enter the MySQL login command on the command line:

mysql –local-infile=1 -u root -p 

Setting variable: set global local_ infile=1;

View variables: show global variables like ‘local_ infile’;

mysql> show global variables like ‘local_ infile’;
+—————+——-+
| Variable_ name | Value |
+—————+——-+
| local_ infile | ON |
+—————+——-+
1 row in set (0.00 sec)

There is no problem importing the file, but the above error will still be prompted when the MySQL service is restarted

Permanent solution: automatically load the configuration and modify the MySQL configuration file when the MySQL service is started

In mysqld.cnf

Add
local under [mysqld]
_ infile = 1  

In mysql.cnf

[mysql]

Add
local under_ infile = 1

MySQL service restart

service mysql restart

Command line view local_ Infile variable status

mysql> SHOW GLOBAL VARIABLES LIKE ‘local_ infile’;
+—————+——-+
| Variable_ name | Value |
+—————+——-+
| local_ infile | ON |
+—————+——-+
1 row in set (0.00 sec)

Description configuration succeeded

Import file OK

  local_ The infile server variable indicates whether the load data local infile command can be used. This variable defaults to on.  
when this variable is off, the load data local infile command on the client is disabled.

Similar Posts: