[英]Access denied when using Upsert with MySQL2 and Rails 4
I'm using the Upsert gem with Rails 4.2.1 and mysql2 gem v0.3.18. 我正在将Upsert gem与Rails 4.2.1和mysql2 gem v0.3.18一起使用。 But I keep getting an "Access denied" error whenever I try to upsert anything.
但是,每当尝试添加任何内容时,我都会不断收到“访问被拒绝”错误。
For example: upsert = Upsert.new User.connection, User.table_name
seems to work fine. 例如:
upsert = Upsert.new User.connection, User.table_name
似乎工作正常。
But when I actually try to use Upsert, like this: upsert.row({id: 123}, name: 'Neat')
但是当我实际尝试使用Upsert时,如下所示:
upsert.row({id: 123}, name: 'Neat')
I get this error: Mysql2::Error: Access denied for user 'developer'@'%' to database 'project_development' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `query' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `execute' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function/mysql.rb:28:in `create!' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function.rb:39:in `initialize' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `new' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `merge_function' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:218:in `row'
我收到此错误:
Mysql2::Error: Access denied for user 'developer'@'%' to database 'project_development' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `query' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `execute' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function/mysql.rb:28:in `create!' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function.rb:39:in `initialize' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `new' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `merge_function' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:218:in `row'
Mysql2::Error: Access denied for user 'developer'@'%' to database 'project_development' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `query' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/connection/Mysql2_Client.rb:7:in `execute' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function/mysql.rb:28:in `create!' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert/merge_function.rb:39:in `initialize' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `new' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:229:in `merge_function' from /usr/local/rvm/gems/ruby-2.2.0@project/gems/upsert-2.1.0/lib/upsert.rb:218:in `row'
I've used Upsert before with PostgreSQL, and it worked beautifully. 我以前在PostgreSQL上使用过Upsert,而且效果很好。 Has anyone else seen this error before with MySQL and Upsert, and if so, do you have any advice?
在使用MySQL和Upsert之前,还有其他人见过此错误吗?如果是,您有什么建议吗?
Hopefully this helps someone else... but it turns out the "developer" user didn't have CREATE PROCEDURE permissions for that MySQL database. 希望这对其他人有帮助...但是事实证明,“开发人员”用户对该MySQL数据库没有CREATE PROCEDURE权限。
Once those permissions were given to the "developer" user, things worked just swell. 一旦将这些权限授予了“开发人员”用户,一切就会膨胀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.