ActiveRecord user

A

angico

Hi,

I'm trying to use ActiveRecord with a database specific user, other than
root, but it always complains about=20

Mysql::Error: Access denied for user 'root'@'localhost' (using password:
YES)

Do I always have to connect as root in order to use ActiveRecord?

Sorry if this question is too silly, but I'm really new to this stuff.

Thanks in advance,

--=20

angico
------

home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Coopera=C3=A7=C3=A3o =C3=A9 muito melhor que competi=C3=A7=C3=A3o!
 
P

Peter Szinek

[Note: parts of this message were removed to make it a legal post.]
Hi,

I'm trying to use ActiveRecord with a database specific user, other
than
root, but it always complains about

Mysql::Error: Access denied for user 'root'@'localhost' (using
password:
YES)

Do I always have to connect as root in order to use ActiveRecord?
No.

Sorry if this question is too silly, but I'm really new to this stuff.

It's not - though it's better suited for the Rails list, but usually
there are enough r4ilz0rz here to help you out.

It would greatly help the investigation if you could specify the
command you are using to connect :)

Cheers,
Peter
___
http://www.rubyrailways.com
http://scrubyt.org
 
J

Jan Pilz

r4ilz0rz r0ckZ! -.-

Look in your config/database.yml File ther you put in the user and
password and btw you could connect with every user you want to use
activerecord.

Regards,



Peter said:
It's not - though it's better suited for the Rails list, but usually
there are enough r4ilz0rz here to help you out.

It would greatly help the investigation if you could specify the
command you are using to connect :)

Cheers,
Peter
___
http://www.rubyrailways.com
http://scrubyt.org


--
Otto Software Partner GmbH

Jan Pilz (e-mail: (e-mail address removed))

Tel. 0351/49723202, Fax: 0351/49723119
01067 Dresden, Freiberger Straße 35 - AG Dresden, HRB 2475
Geschäftsführer: Burkhard Arrenberg, Jens Gruhl
 
A

angico

Em Ter, 2008-11-18 =C3=A0s 21:03 +0900, Peter Szinek escreveu:
It would greatly help the investigation if you could specify the =20
command you are using to connect :)
=20
Cheers,
Peter
___
http://www.rubyrailways.com
http://scrubyt.org

Hi, Peter.

The commands are as follows, from within irb:

require 'rubygems'

=3D> true

require 'active_record'

=3D> true

ActiveRecord::Base.establish_connection:)user =3D> 'the_user', :password =
=3D> 'the_password', :adapter =3D> 'mysql', :database =3D> 'the_db')

=3D> #<ActiveRecord::Base::ConnectionSpecification:0x7f45208db910 @config=
=3D{:adapter=3D>"mysql", :user=3D>"the_user", :password=3D>"the_password", =
:database=3D>"the_db"}, @adapter_method=3D"mysql_connection">

load 'tbl.rb'

=3D> true

Tbl.class

=3D> Class

Tbl.columns

Mysql::Error: Access denied for user 'root'@'localhost' (using password: YE=
S)

-----------
But if I establish_connection with :user =3D> 'root' and :password =3D> 'ro=
ots passwd', then this last command succeeds! What's the problem with 'the_=
user'? I have granted the_user all permissions on database the_db. Just can=
't find out why it insists in use 'root'@'localhost'!

Can you give me any hints?

Thank you very much,


--=20

angico
------

home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Coopera=C3=A7=C3=A3o =C3=A9 muito melhor que competi=C3=A7=C3=A3o!
 
A

angico

Em Ter, 2008-11-18 =C3=A0s 21:29 +0900, Jan Pilz escreveu:
r4ilz0rz r0ckZ! -.-
=20
Look in your config/database.yml File ther you put in the user and=20
password and btw you could connect with every user you want to use=20
activerecord.
=20
Regards,
=20

Well, I am not using Rails. I just want to use ActiveRecord with an
FXRuby app. Is it impossible?


--=20

angico
------

home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Coopera=C3=A7=C3=A3o =C3=A9 muito melhor que competi=C3=A7=C3=A3o!
 
P

Peter Szinek

[Note: parts of this message were removed to make it a legal post.]
load 'tbl.rb'

=> true

Tbl.class

=> Class

Tbl.columns

Mysql::Error: Access denied for user 'root'@'localhost' (using
password: YES)


By any chance, isn't it possible that tbl.rb is hijacking your
connection? e.g. it contains a line

ActiveRecord::Base.establish_connection:)user => 'root', :password =>
'bad_password', :adapter => 'mysql', :database => 'the_db')

Peter
___
http://www.rubyrailways.com
http://scrubyt.org
 
A

angico

Em Ter, 2008-11-18 =C3=A0s 21:46 +0900, Peter Szinek escreveu:
By any chance, isn't it possible that tbl.rb is hijacking your =20
connection? e.g. it contains a line
=20
ActiveRecord::Base.establish_connection:)user =3D> 'root', :password =3D>= =20
'bad_password', :adapter =3D> 'mysql', :database =3D> 'the_db')
=20
Peter
___
http://www.rubyrailways.com
http://scrubyt.org
=20

No, Peter. tbl.rb just contains a single line:

class Tbl < ActiveRecord::Base ; end

Also, config/database.yml just holds some sqlite3 databases info.
Nothing related to the_db.

That's all.

--=20

angico
------

home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Coopera=C3=A7=C3=A3o =C3=A9 muito melhor que competi=C3=A7=C3=A3o!
 
A

angico

Hi, guys.

I'm sorry. I'm very sorry! The problem was on me. And although I have expos=
ed it to you, nobody seemed to catch it:

I was using a wrong key in the call to ActiveRecord::Base.establish_connect=
ion, as shown below:

ActiveRecord::Base.establish_connection(
:adapter =3D> "mysql",
:database =3D> "the_db",
:user =3D> "the_user",
:password =3D> "the_password"
)

The problem was with key "user". The correct would be "username". Now it wo=
rks fine!

Sorry, again. The fault was on me.

Thank you all for the attention,

--=20

angico
------

home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I

Coopera=C3=A7=C3=A3o =C3=A9 muito melhor que competi=C3=A7=C3=A3o!
 
S

Saji N Hameed

* angico said:
Hi, guys.
=20
I'm sorry. I'm very sorry! The problem was on me. And although I have exp=
osed it to you, nobody seemed to catch it:

Also while on it, you may want to check out sequel.rubyforge.org
for your project

require 'sequel'
dbname=3D"mysql://#{user}:#{pass}@localhost/#{db_name}"
db =3D Sequel.connect(dbname)

saji
------
=20
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
=20
Coopera=E7=E3o =E9 muito melhor que competi=E7=E3o!
=20
------
contatos:
email: (e-mail address removed)
skype: an.gi.co
------
=20
=20
=20
=20

--=20
Saji N. Hameed

APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F =20
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 (e-mail address removed)
KOREA
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top