"mysql 8.0" 本地 infile 失败 我尝试并显示设置。会不会是权限问题?
"mysql 8.0" local infile fails I tried and display the settings. Could it be permission issues?
以下是我的会话,我的数据位于 owner/group of mysql
的目录中
mysql -u root -p
输入密码:
欢迎使用 MySQL 监视器。命令以 ; 结尾或\g。
您的 MySQL 连接 ID 是 8
服务器版本:8.0.18 MySQL 社区服务器 - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set global local_infile = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> use SSC;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> load data local infile '/storage/temp/myest1.csv' into table SSC fields terminated by ',' lines terminated by '\n' ignore 1 lines;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> show variables like "local_infile";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set (0.00 sec)
mysql> load data local infile '/storage/temp/myest1.csv' into table SSC;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> load data local infile 'myest1.csv' into table SSC;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> SELECT @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| /storage/temp/ |
+---------------------------+
1 row in set (0.00 sec)
如果您将 LOCAL 选项与 LOAD DATA INFILE 结合使用,则 secure_file_priv
不会用于您加载的文件的位置。该文件由客户端加载,因此您使用的路径不在服务器上,而是在客户端上。如果你给出一个相对路径,它是相对于你启动客户端时的当前工作目录。
但是,服务器和客户端都必须启用 --local-infile
选项。
您已经在服务器中设置了该选项,但您还需要在客户端中像这样设置它:
mysql --local-infile -u root -p
我认为您收到的错误消息非常无用。我记录了一个关于它的错误:
Bug #94396 Error message too broad: The used command is not allowed with this MySQL version
如果您同意,请为该错误报告投票!
以下是我的会话,我的数据位于 owner/group of mysql
的目录中
mysql -u root -p
输入密码:
欢迎使用 MySQL 监视器。命令以 ; 结尾或\g。
您的 MySQL 连接 ID 是 8
服务器版本:8.0.18 MySQL 社区服务器 - GPL
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set global local_infile = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> use SSC;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> load data local infile '/storage/temp/myest1.csv' into table SSC fields terminated by ',' lines terminated by '\n' ignore 1 lines;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> show variables like "local_infile";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set (0.00 sec)
mysql> load data local infile '/storage/temp/myest1.csv' into table SSC;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> load data local infile 'myest1.csv' into table SSC;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> SELECT @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| /storage/temp/ |
+---------------------------+
1 row in set (0.00 sec)
如果您将 LOCAL 选项与 LOAD DATA INFILE 结合使用,则 secure_file_priv
不会用于您加载的文件的位置。该文件由客户端加载,因此您使用的路径不在服务器上,而是在客户端上。如果你给出一个相对路径,它是相对于你启动客户端时的当前工作目录。
但是,服务器和客户端都必须启用 --local-infile
选项。
您已经在服务器中设置了该选项,但您还需要在客户端中像这样设置它:
mysql --local-infile -u root -p
我认为您收到的错误消息非常无用。我记录了一个关于它的错误:
Bug #94396 Error message too broad: The used command is not allowed with this MySQL version
如果您同意,请为该错误报告投票!