我正在使用安装了 MySQL 8.0 的 Windows。
我已经检查了已发布在 stackoverflow 上的解决方案,但这些解决方案没有立竿见影的效果。
我已经用 SET GLOBAL local_infile = 1; 设置了全局变量
此选项现在似乎已启用,但 MySQL 不断抛出以下错误:
错误代码:
- The used command is not allowed with this MySQL version
谁能帮我解决这个问题?
最佳答案
尝试:
文件:Z:\Path\To\MySQL\Files\my_file.csv:
1,"a string"
2,"a string containing a , comma"
3,"a string containing a \" quote"
4,"a string containing a \", quote and comma"
MySQL 命令行:
Z:\>mysql
Enter password: **************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> DROP TABLE IF EXISTS `_`.`my_table`;
Query OK, 0 rows affected, 1 warning (0.03 sec)
mysql> CREATE TABLE IF NOT EXISTS `_`.`my_table` (
-> `col0` INT NOT NULL PRIMARY KEY,
-> `col1` VARCHAR(50) NOT NULL
-> );
Query OK, 0 rows affected (0.45 sec)
mysql> SHOW VARIABLES WHERE `variable_name` = 'secure_file_priv';
+------------------+-------------------------+
| Variable_name | Value |
+------------------+-------------------------+
| secure_file_priv | Z:\Path\To\MySQL\Files\ |
+------------------+-------------------------+
1 row in set (0.00 sec)
mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
-> INTO TABLE `_`.`my_table`
-> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n';
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> SELECT @@GLOBAL.`local_infile`;
+-------------------------+
| @@GLOBAL.`local_infile` |
+-------------------------+
| 0 |
+-------------------------+
1 row in set (0.00 sec)
mysql> SET @@GLOBAL.`local_infile` := 1;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @@GLOBAL.`local_infile`;
+-------------------------+
| @@GLOBAL.`local_infile` |
+-------------------------+
| 1 |
+-------------------------+
1 row in set (0.00 sec)
mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
-> INTO TABLE `_`.`my_table`
-> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n';
ERROR 1148 (42000): The used command is not allowed with this MySQL version
mysql> SELECT `col0`, `col1`
-> FROM `_`.`my_table`;
Empty set (0.00 sec)
mysql> exit
Bye
Z:\>mysql --local-infile=1
Enter password: **************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, 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> SELECT @@GLOBAL.`local_infile`;
+-------------------------+
| @@GLOBAL.`local_infile` |
+-------------------------+
| 1 |
+-------------------------+
1 row in set (0.00 sec)
mysql> LOAD DATA LOCAL INFILE 'Z:\\Path\\To\\MySQL\\Files\\my_file.csv'
-> INTO TABLE `_`.`my_table`
-> FIELDS TERMINATED BY ',' ENCLOSED BY '"'
-> LINES TERMINATED BY '\r\n';
Query OK, 4 rows affected (0.19 sec)
Records: 4 Deleted: 0 Skipped: 0 Warnings: 0
mysql> SELECT `col0`, `col1`
-> FROM `_`.`my_table`;
+------+------------------------------------------+
| col0 | col1 |
+------+------------------------------------------+
| 1 | a string |
| 2 | a string containing a , comma |
| 3 | a string containing a " quote |
| 4 | a string containing a ", quote and comma |
+------+------------------------------------------+
4 rows in set (0.00 sec)
关于WINDOWS 上的 MySQL LOAD DATA LOCAL INFILE 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50699458/
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub