I am trying to load data into mysql database using
LOAD DATA LOCAL INFILE A.txt INTO DB LINES TERMINATED BY '|';
the topic of this question is the response I get. I understand the local data offloading is off by default and I have to enable it using a the command local-infile=1
but I do not know where to place this command.
To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option. For the mysqlimport client, local data loading is not used by default. To disable or enable it explicitly, use the --local=0 or --local[=1] option.
MySQL Client allows getting the version info by running the SELECT VERSION() command in the MySQL database. Here is the syntax for MySQL SELECT VERSION query: SELECT VERSION();
To allow LOAD DATA LOCAL INFILE to succeed, you must set AllowLoadLocalInfile=true in the client's connection string. If you use MySqlBulkLoader and set Local=true , then everything should work by default. If you are manually creating a LOAD DATA LOCAL INFILE statement, you must be connected to a trusted server.
Both the server and the client can restrict use of the LOCAL keyword for LOAD DATA and LOAD XML. The same error message is produced if either one blocks it. To cause the server to permit access, set the local_infile variable with SET GLOBAL local_infile = 1; or check it with SHOW GLOBAL VARIABLES LIKE 'local_infile'; .
You can specify that as an additional option when setting up your client connection:
mysql -u myuser -p --local-infile somedatabase
This is because that feature opens a security hole. So you have to enable it in an explicit manner in case you really want to use it.
Both client and server should enable the local-file option. Otherwise it doesn't work.To enable it for files on the server side server add following to the my.cnf
configuration file:
loose-local-infile = 1
I find the answer here.
It's because the server variable local_infile
is set to FALSE|0. Refer from the document.
You can verify by executing:
SHOW VARIABLES LIKE 'local_infile';
If you have SUPER privilege you can enable it (without restarting server with a new configuration) by executing:
SET GLOBAL local_infile = 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With