mysql在windows上加载数据本地填充不工作

64jmpszr  于 2021-06-20  发布在  Mysql
关注(0)|答案(5)|浏览(495)

我使用的是安装了mysql 8.0的windows。
我已经检查了stackoverflow上已经发布的解决方案,但是没有立即的结果。
我已经用 SET GLOBAL local_infile = 1; 此选项现在似乎已启用,但mysql不断抛出以下错误:
错误代码:
此mysql版本不允许使用used命令
有人能帮我纠正这种行为吗?

bmp9r5qi

bmp9r5qi1#

windows10用户:确认windows使用哪个帐户来运行mysql服务是多么重要,这一点值得重复。
这个问题在Windows10的MySQL8.0.21中仍然存在。与 LOAD DATA INFILE (而不是 LOAD DATA INFILE LOCAL ,即使在同一桌面上运行客户端和服务器,也需要额外的文件传输)我开始收到以下错误: not found (OS errno 13 - Permission denied) 出于某种原因,mysql决定选择“networkservices”,可能是因为我将安装从默认的c:驱动器移到了d:
不:

最初的安装设置了local,我选择了“local system account”单选按钮,这就为我解决了这个问题。
对:

mysql文档鼓励将mysql作为windows服务在windows上运行,但是对于指定哪个帐户作为服务的登录没有给出建议。
和其他许多人一样,我浏览了所有选项(local\u infle等),但直到看到来自cesaring的答案才检查服务登录,我现在欠他一杯啤酒或咖啡。

flseospp

flseospp2#

我有同样的问题后,搜索,我解决了从查询中删除本地关键字的问题。

  1. SET GLOBAL local_infile = 1;
  2. SHOW VARIABLES LIKE 'local_infile';

查询应返回:on
查询应如下所示:

  1. load data infile 'C:\\CA_DRU_proj_2010-2060.csv'
  2. into table pop_proj
  3. fields terminated by ','
  4. enclosed by '"'
  5. lines terminated by '\n'
  6. ignore 1 lines;

你应该注意到,我删除了本地关键字从这里,现在它的工作正常。

z9gpfhce

z9gpfhce3#

截至2019年1月,这是mysql workbench 8.0.12的一个未解决的错误。请参见:https://bugs.mysql.com/bug.php?id=91891 .
但是,如果“local\u infle”全局变量已设置为1,则通过cli执行相同的命令应该可以工作:
设置@@global.local\u infle=1;

rdrgkggo

rdrgkggo4#

我一直在处理一个类似的问题,在windows上使用mysql 8.0.19。我没有使用local关键字,而是使用windows服务管理器(在资源管理器任务栏上键入services),右键单击mysql80->选择properties,然后在logon选项卡上,将logon as:value更改为local system account。

8qgya5xd

8qgya5xd5#

尝试:
文件: Z:\Path\To\MySQL\Files\my_file.csv :

  1. 1,"a string"
  2. 2,"a string containing a , comma"
  3. 3,"a string containing a \" quote"
  4. 4,"a string containing a \", quote and comma"

mysql命令行:

  1. Z:\>mysql
  2. Enter password:**************
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 1
  5. Server version: 8.0.11 MySQL Community Server - GPL
  6. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> DROP TABLE IF EXISTS `_`.`my_table`;
  12. Query OK, 0 rows affected, 1 warning (0.03 sec)
  13. mysql> CREATE TABLE IF NOT EXISTS `_`.`my_table` (
  14. -> `col0` INT NOT NULL PRIMARY KEY,
  15. -> `col1` VARCHAR(50) NOT NULL
  16. -> );
  17. Query OK, 0 rows affected (0.45 sec)
  18. mysql> SHOW VARIABLES WHERE `variable_name` = 'secure_file_priv';
  19. +------------------+-------------------------+
  20. | Variable_name | Value |
  21. +------------------+-------------------------+
  22. | secure_file_priv | Z:\Path\To\MySQL\Files\ |
  23. +------------------+-------------------------+
  24. 1 row in set (0.00 sec)
  25. mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
  26. -> INTO TABLE `_`.`my_table`
  27. -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  28. -> LINES TERMINATED BY '\r\n';
  29. ERROR 1148 (42000): The used command is not allowed with this MySQL version
  30. mysql> SELECT @@GLOBAL.`local_infile`;
  31. +-------------------------+
  32. | @@GLOBAL.`local_infile` |
  33. +-------------------------+
  34. | 0 |
  35. +-------------------------+
  36. 1 row in set (0.00 sec)
  37. mysql> SET @@GLOBAL.`local_infile` := 1;
  38. Query OK, 0 rows affected (0.00 sec)
  39. mysql> SELECT @@GLOBAL.`local_infile`;
  40. +-------------------------+
  41. | @@GLOBAL.`local_infile` |
  42. +-------------------------+
  43. | 1 |
  44. +-------------------------+
  45. 1 row in set (0.00 sec)
  46. mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
  47. -> INTO TABLE `_`.`my_table`
  48. -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  49. -> LINES TERMINATED BY '\r\n';
  50. ERROR 1148 (42000): The used command is not allowed with this MySQL version
  51. mysql> SELECT `col0`, `col1`
  52. -> FROM `_`.`my_table`;
  53. Empty set (0.00 sec)
  54. mysql> exit
  55. Bye
  56. Z:\>mysql --local-infile=1
  57. Enter password:**************
  58. Welcome to the MySQL monitor. Commands end with ; or \g.
  59. Your MySQL connection id is 2
  60. Server version: 8.0.11 MySQL Community Server - GPL
  61. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  62. Oracle is a registered trademark of Oracle Corporation and/or its
  63. affiliates. Other names may be trademarks of their respective
  64. owners.
  65. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  66. mysql> SELECT @@GLOBAL.`local_infile`;
  67. +-------------------------+
  68. | @@GLOBAL.`local_infile` |
  69. +-------------------------+
  70. | 1 |
  71. +-------------------------+
  72. 1 row in set (0.00 sec)
  73. mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
  74. -> INTO TABLE `_`.`my_table`
  75. -> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  76. -> LINES TERMINATED BY '\r\n';
  77. Query OK, 4 rows affected (0.19 sec)
  78. Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
  79. mysql> SELECT `col0`, `col1`
  80. -> FROM `_`.`my_table`;
  81. +------+------------------------------------------+
  82. | col0 | col1 |
  83. +------+------------------------------------------+
  84. | 1 | a string |
  85. | 2 | a string containing a , comma |
  86. | 3 | a string containing a " quote |
  87. | 4 | a string containing a ", quote and comma |
  88. +------+------------------------------------------+
  89. 4 rows in set (0.00 sec)
展开查看全部

相关问题