angico
November 18, 2008, 12:32pm
1
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?
Sorry if this question is too silly, but I’m really new to this stuff.
Thanks in advance,
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Cooperação é muito melhor que competição!
angico
November 18, 2008, 1:07pm
2
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
angico
November 18, 2008, 1:33pm
3
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 S. schrieb:
No.
Peter
http://www.rubyrailways.com
http://scrubyt.org
–
Otto Software Partner GmbH
Jan P. (e-mail: [email protected] )
Tel. 0351/49723202, Fax: 0351/49723119
01067 Dresden, Freiberger Straße 35 - AG Dresden, HRB 2475
Geschäftsführer: Burkhard Arrenberg, Jens Gruhl
angico
November 18, 2008, 1:36pm
4
Em Ter, 2008-11-18 Ã s 21:03 +0900, Peter S. escreveu:
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
Hi, Peter.
The commands are as follows, from within irb:
require ‘rubygems’
=> true
require ‘active_record’
=> true
ActiveRecord::Base.establish_connection(:user => ‘the_user’, :password
=> ‘the_password’, :adapter => ‘mysql’, :database => ‘the_db’)
=> #<ActiveRecord::Base::ConnectionSpecification:0x7f45208db910
@config={:adapter=>“mysql”, :user=>“the_user”,
:password=>“the_password”, :database=>“the_db”},
@adapter_method=“mysql_connection”>
load ‘tbl.rb’
=> true
Tbl.class
=> Class
Tbl.columns
Mysql::Error: Access denied for user ‘root’@‘localhost’ (using password:
YES)
But if I establish_connection with :user => ‘root’ and :password =>
‘roots 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,
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Cooperação é muito melhor que competição!
angico
November 18, 2008, 1:51pm
5
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
angico
November 18, 2008, 1:51pm
6
On 2008.11.18., at 13:40, angico wrote:
Well, I am not using Rails. I just want to use ActiveRecord with an
FXRuby app. Is it impossible?
Definitely not! In this case you are even on the right list
http://www.rubyrailways.com
http://scrubyt.org
angico
November 18, 2008, 1:45pm
7
Em Ter, 2008-11-18 Ã s 21:29 +0900, Jan P. escreveu:
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,
Well, I am not using Rails. I just want to use ActiveRecord with an
FXRuby app. Is it impossible?
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Cooperação é muito melhor que competição!
angico
November 18, 2008, 2:13pm
8
Hi, guys.
I’m sorry. I’m very sorry! The problem was on me. And although I have
exposed it to you, nobody seemed to catch it:
I was using a wrong key in the call to
ActiveRecord::Base.establish_connection, as shown below:
ActiveRecord::Base.establish_connection(
:adapter => “mysql”,
:database => “the_db”,
:user => “the_user”,
:password => “the_password”
)
The problem was with key “user”. The correct would be “username”. Now it
works fine!
Sorry, again. The fault was on me.
Thank you all for the attention,
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Cooperação é muito melhor que competição!
angico
November 18, 2008, 1:58pm
9
Em Ter, 2008-11-18 Ã s 21:46 +0900, Peter S. escreveu:
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.
–
angico
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
Cooperação é muito melhor que competição!
angico
November 18, 2008, 2:21pm
10
Hi, guys.
I’m sorry. I’m very sorry! The problem was on me. And although I have exposed 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=“mysql://#{user}:#{pass}@localhost /#{db_name}”
db = Sequel.connect(dbname)
saji
–
Saji N. Hameed
APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 [email protected]
KOREA