ERROR 1148: The used command is not allowed with t

2019-01-08 22:01发布

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.

标签: mysql sql import
4条回答
做个烂人
2楼-- · 2019-01-08 22:42

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
查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-08 22:44

http://dev.mysql.com/doc/refman/5.6/en/load-data-local.html

Put this in my.cnf - the [client] section should already be there (if you're not too concerned about security).

[client]
loose-local-infile=1
查看更多
戒情不戒烟
4楼-- · 2019-01-08 22:46

All of this didn't solve it for me on my brand new Ubuntu 15.04.

I removed the LOCAL and got this command:

LOAD DATA
INFILE A.txt
INTO DB
LINES TERMINATED BY '|';

but then I got:

MySQL said: File 'A.txt' not found (Errcode: 13 - Permission denied)

That led me to this answer from Nelson to another question on stackoverflow which solved the issue for me!

查看更多
贪生不怕死
5楼-- · 2019-01-08 22:57

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;
查看更多
登录 后发表回答