Access denied when using Upsert with MySQL2 and Rails 4

122 views Asked by At

I'm using the Upsert gem with Rails 4.2.1 and 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.

But when I actually try to use Upsert, like this: 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'

I've used Upsert before with PostgreSQL, and it worked beautifully. Has anyone else seen this error before with MySQL and Upsert, and if so, do you have any advice?

1

There are 1 answers

0
Joe On

Hopefully this helps someone else... but it turns out the "developer" user didn’t have CREATE PROCEDURE permissions for that MySQL database.

Once those permissions were given to the "developer" user, things worked just swell.