Connect with local-infile Option in MySql Workbench

廉价感情. 提交于 2020-05-13 19:26:27

问题


Is it possible to connect with the local-infile Option in MySql Workbench? Like this:

mysql -h 10.152.xx.xx -u USER -p --local-infile MyDatabase

The reason is, that LOAD DATA LOCAL INFILE seems to work only with this option. Even if

SHOW GLOBAL VARIABLES LIKE 'local_infile'; 

returns

'local_infile', 'ON'

LOAD DATA LOCAL INFILE yields

Error Code: 1148. The used command is not allowed with this MySQL version

回答1:


Edit the connection settings in MySQL Workbench.

Under the Advanced tab, add the following option to the connector options in the others window:

OPT_LOCAL_INFILE=1




回答2:


This not working is a verified bug since Workbench 8.0.12. Solution from the bug's comments:

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';. Alternatively, edit mysql's config to include local_infile=1.

To cause Workbench to permit access, edit the connection (click the wrench icon by the MySQL Connections, or right-click on a particular connection and choose Edit Connection...). On the Advanced tab, in the "Others:" box, add the line OPT_LOCAL_INFILE=1

I just ran into this problem and setting the variable as well as the MySQL Workbench config solved it.




回答3:


If you are using MySQL Workbench 8.0.12 (more recent encountering of this issue), this bug might explain,

https://bugs.mysql.com/bug.php?id=91891

I just upgraded from MySQLWorkbench 6.x to 8.0.12, and the LOCAL INFILE broke with "Error code 1148. The used command is not allowed with the MySQL version." without any other changes (GLOBAL variable local_infile is ON).

P.S. I also tried with the local_infile=1 parameter in the Advanced preferences, and it does not resolve the issue. For the time being, I rolled back to the older version of workbench till the bug is fixed.




回答4:


Did you try to add that parameter to the connection settings (Advanced -> Others)? Haven't done this myself yet, but worth trying: enter image description here



来源:https://stackoverflow.com/questions/31450389/connect-with-local-infile-option-in-mysql-workbench

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!