require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql2',
:database => 'vft',
:user => 'vft',
:password => 'vft_password'
)
class Attachment < ActiveRecord::Base
end
Attachment.all
This code throws Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error) with both mysql and mysql2 gems. The vft user is real and works with vft database through phpmyadmin or console. Here is my environment:
Debian Squeeze,
Rails 3.2,
RVM Ruby 1.9.3
Same code works good on my local PC(Ubuntu), the problem occurs only on remote VDS…
I guess you should replace :user with :username.