如何“将数据加载到文件中”在亚马逊 RDS 上?
不确定这是否是一个更适合服务器故障的问题,但我最近一直在搞乱亚马逊 RDS,并且在为我的网络主机 mysql 用户获取“文件”权限时遇到问题。
我假设一个简单的:
grant file on *.* to 'webuser@'%';
可以工作,但事实并非如此,而且我似乎也无法对我的“root”用户执行此操作。什么给?我们使用加载数据的原因是因为它一次执行数千个插入的速度非常快。
有人知道如何解决这个问题还是我需要找到不同的方法?
此页面 http://docs.amazonwebservices.com/ AmazonRDS/latest/DeveloperGuide/index.html?Concepts.DBInstance.html 似乎表明我需要找到一种不同的方法来解决这个问题。
帮助?
更新 我不想导入数据库——我只是想使用文件加载选项一次插入数十万行。
深入研究后,我们得到的是:
mysql> grant file on *.* to 'devuser'@'%';
ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)
mysql> select User, File_priv, Grant_priv, Super_priv from mysql.user;
+----------+-----------+------------+------------+
| User | File_priv | Grant_priv | Super_priv |
+----------+-----------+------------+------------+
| rdsadmin | Y | Y | Y |
| root | N | Y | N |
| devuser | N | N | N |
+----------+-----------+------------+------------+
not sure if this is a question better suited for serverfault but I've been messing with amazon RDS lately and was having trouble getting 'file' privileges to my web host mysql user.
I'd assume that a simple:
grant file on *.* to 'webuser@'%';
would work but it does not and I can't seem to do it with my 'root' user as well. What gives? The reason we use load data is because it is super super fast for doing thousands of inserts at once.
anyone know how to remedy this or do I need to find a different way?
This page, http://docs.amazonwebservices.com/AmazonRDS/latest/DeveloperGuide/index.html?Concepts.DBInstance.html seems to suggest that I need to find a different way around this.
Help?
UPDATE
I'm not trying to import a database -- I just want to use the file load option to insert several hundred-thousand rows at a time.
after digging around this is what we have:
mysql> grant file on *.* to 'devuser'@'%';
ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: YES)
mysql> select User, File_priv, Grant_priv, Super_priv from mysql.user;
+----------+-----------+------------+------------+
| User | File_priv | Grant_priv | Super_priv |
+----------+-----------+------------+------------+
| rdsadmin | Y | Y | Y |
| root | N | Y | N |
| devuser | N | N | N |
+----------+-----------+------------+------------+
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您需要使用 LOAD DATA LOCAL INFILE ,因为该文件不在 MySQL 服务器上,而是在您运行命令的计算机上。
根据下面的评论,您可能还需要包含该标志:
You need to use
LOAD DATA LOCAL INFILE
as the file is not on the MySQL server, but is on the machine you are running the command from.As per comment below you may also need to include the flag:
也遇到了这个问题,尝试在 Windows 上使用 MySQL Workbench 将 .csv 数据从我的本地计算机上传到 AWS RDS 实例。
我需要的添加是在以下位置添加
OPT_LOCAL_INFILE=1
:Connection >高级>其他的。注意需要使用 CAPS。我在 AWS 开发者论坛中找到了 PeterMag 的答案。
更多信息:
SHOW VARIABLES LIKE 'local_infile';
已返回ON
查询是:
从上面引用的答案源复制:
Also struggled with this issue, trying to upload .csv data into AWS RDS instance from my local machine using MySQL Workbench on Windows.
The addition I needed was adding
OPT_LOCAL_INFILE=1
in: Connection > Advanced > Others. Note CAPS was required.I found this answer by PeterMag in AWS Developer Forums.
For further info:
SHOW VARIABLES LIKE 'local_infile';
already returnedON
and the query was:
Copying from the answer source referenced above:
无论它的价值如何......您可以将 LOCAL 操作数添加到 LOAD DATA INFILE 而不是使用 mysqlimport 来解决此问题。
LOAD DATA LOCAL INFILE ...
这无需授予 FILE 权限即可工作。
For whatever it's worth... You can add the LOCAL operand to the LOAD DATA INFILE instead of using
mysqlimport
to get around this problem.LOAD DATA LOCAL INFILE ...
This will work without granting FILE permissions.
很确定您还不能做到这一点,因为您没有 RDS 的最高级别 MySQL 权限。我们只做了一些测试,但导入数据库的最简单方法似乎是从源框中通过管道传输它,例如
Pretty sure you can't do it yet, as you don't have the highest level MySQL privileges with RDS. We've only done a little testing, but the easiest way to import a database seems to be to pipe it from the source box, e.g.
有两种方法可以将批量数据导入 Amazon MySQL RDS。您可以根据您的方便选择以下任何一个。
使用导入实用程序。
通过管道进入 mysql 命令发送批量插入 SQL。
Importing bulk data into Amazon MySQL RDS is possible two ways. You could choose anyone of below as per your convenience.
Using Import utility.
Sending a bulk insert SQL by piping into into mysql command.
我遇到了类似的问题。事实上,我试图导入数据库,但条件应该是相同的 - 由于某些表的大小、不稳定的连接以及对适度恢复功能的渴望,我需要使用加载数据。
我同意 chris finne 的观点,即不指定本地选项可能会导致该错误。经过多次调整和启动后,我发现 Maatkit 提供了 mk-parallel-restore 工具我需要一些优秀的附加功能。它可能非常适合您的用例。
I ran into similar issues. I was in fact trying to import a database but the conditions should be the same - I needed to use load data due to the size of some tables, a spotty connection, and the desire for a modest resume functionality.
I agree with chris finne that not specifying the local option can lead to that error. After many fits and starts I found that the mk-parallel-restore tool from Maatkit provided what I needed with some excellent extra features. It might be a great match for your use case.