P粉3168908842023-08-30 00:09:36
If the LOCAL feature is disabled on the server or client side, a client attempting to issue a LOAD DATA LOCAL statement will receive the following error message:
ERROR 3950 (42000): Loading local data is disabled; this must be enabled on both the client and server side
I encountered the same problem when I wanted to load the text file pet.txt into the pet table following Mysql's tutorial: https://dev.mysql.com/doc/refman/8.0/en/ loading-tables.html
After searching online, I fixed it with the following steps:
mysql> SET GLOBAL local_infile=1; Query OK, 0 rows affected (0.00 sec)
mysql> quit Bye
mysql --local-infile=1 -u root -p1
This variable controls the server-side LOCAL functionality of the LOAD DATA statement. Depending on the local_infile setting, the server denies or allows clients with LOCAL enabled on the client to load local data. To explicitly cause the server to deny or allow LOAD DATA LOCAL statements (regardless of how the client program and libraries are configured at build time or run time), start mysqld with local_infile disabled or enabled, respectively. local_infile can also be set at runtime.
mysql> use menagerie Database changed mysql> load data local infile '/path/pet.txt' into table pet; Query OK, 8 rows affected, 7 warnings (0.00 sec)
Is it effective?
references:
https://dev.mysql. com/doc/refman/8.0/en/load-data-local-security.html https://dev.mysql.com/doc /refman/8.0/en/source-configuration-options.html#option_cmake_enabled_local_infile https://dev.mysql.com/doc /refman/8.0/en/server-system-variables.html#sysvar_local_infile