Here is the code:
require 'active_record'
ActiveRecord::Base.establish_connection(
adapter: 'mysql',
user: 'dev',
database: 'dev_db'
)
class PageModel < ActiveRecord::Base
end
p PageModel.first
and here is the error:
mysql_adapter.rb:411:in `real_connect': Access denied for user 'root'@'localhost' (using password: NO) (Mysql::Error)
Why is it trying to connect as root?
MySQL dev user exists, has no password and has full access to dev_db database.
Tried to connect through both TCP and unix socket, same error.
DataMapper connections works just well.
$ gem list |grep mysql
mysql (2.8.1)
$ gem list |grep activere
activerecord (3.2.9)
The correct key is
:username, not:user.