Simple database connection

J

jrq

Apologies for being really dumb today. I'm sure this is something
really basic.
I'm trying to open a connection to a MySQL database using mysql2 using
the following:

require "rubygems"
require "mysql2"
mysql = Mysql2::Client.new:)host => 'localhost', :user =>
'user1', :password => 'XXXX', :database => 'www_wpportal')
res = mysql.query("select * from contact_tag")

But I keep getting this message when I run it:

/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.4/lib/mysql2/client.rb:
36:in `connect': Access denied for user 'root'@'localhost' (using
password: YES) (Mysql2::Error)

I don't understand where it's getting the "root@localhost" from.

Any assistance greatly appreciated.
 
J

jrq

Apologies for being really dumb today.  I'm sure this is something
really basic.
I'm trying to open a connection to a MySQL database using mysql2 using
the following:

require "rubygems"
require "mysql2"
mysql = Mysql2::Client.new:)host => 'localhost', :user =>
'user1', :password => 'XXXX', :database => 'www_wpportal')
res = mysql.query("select * from contact_tag")

But I keep getting this message when I run it:

/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.4/lib/mysql2/client.rb:
36:in `connect': Access denied for user 'root'@'localhost' (using
password: YES) (Mysql2::Error)

I don't understand where it's getting the "root@localhost" from.

Any assistance greatly appreciated.

Of course I figured it out 2 minutes after posting. It's "username"
not "user".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top