Basic trouble-shooting 101:
If the literal strings work, and variable assignments don't, then suspect your variable assignments; Something could be wrong with one of them, such as an invisible character.
Try:
vars = ('localhost','root','admin','one')
Mysql.new(*vars)
Then try:
vars = %w(localhost root admin one)
Mysql.new(*vars)
or:
host, username, password, db = %w(localhost root admin one)
Mysql.new(host, username, password, db)
or:
host, username, password, db = 'localhost','root','admin','one'
Mysql.new(host, username, password, db)
The idea is to start with what you know works, and work backwards until assigning to variables works, or it breaks. At that point you've either fixed the problem (possibly without knowing why), or you've learned what broke it. Either way you're ahead.
You say:
When I print all the variables the correct values are printed.
HOW are you printing the variables? We can't see your terminal, and you didn't give us that information. If it's an invisible character, which are common culprits when copying and pasting text, it might not show up when printing. Inspecting the variables should help, as they should display as escaped values:
password = "root\u00a0"
puts password
# >> root
puts password.inspect
# >> "root "
puts password.chars
# >> r
# >> o
# >> o
# >> t
# >>
puts password.unpack('C*').map{ |s| s.to_s(16) }
# >> 72
# >> 6f
# >> 6f
# >> 74
# >> c2
# >> a0
Otherwise, I revert back to my original comment, that this is a problem with how you set up your MySQL root account and you should read "Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)".