Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR 1148: The used command is not allowed with this MySQL version

Tags:

import

sql

mysql

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.

like image 588
sosytee Avatar asked Aug 26 '13 06:08

sosytee


People also ask

How do I enable local data loading in MySQL?

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.

How do I determine MySQL version?

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();

How do I configure AllowLoadLocalInfile true?

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.

How do I connect to the local Infile system variable?

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'; .


2 Answers

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 
like image 66
arkascha Avatar answered Oct 13 '22 04:10

arkascha


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; 
like image 32
Java Xu Avatar answered Oct 13 '22 06:10

Java Xu