Forum: Ruby ActiveRecord user

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dbf12550cae38b163a584a826fc6d9b5?d=identicon&s=25 angico (Guest)
on 2008-11-18 12:32
(Received via mailing list)
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!
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2008-11-18 13:07
(Received via mailing list)
> 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
680459fdb69cf1e6aa244881b069581c?d=identicon&s=25 Jan Pilz (Guest)
on 2008-11-18 13:33
(Received via mailing list)
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 Szinek schrieb:
> No.
> Peter
> ___
> http://www.rubyrailways.com
> http://scrubyt.org


--
Otto Software Partner GmbH

Jan Pilz (e-mail: Jan.Pilz@osp-dd.de)

Tel. 0351/49723202, Fax: 0351/49723119
01067 Dresden, Freiberger Straße 35 - AG Dresden, HRB 2475
Geschäftsführer: Burkhard Arrenberg, Jens Gruhl
Dbf12550cae38b163a584a826fc6d9b5?d=identicon&s=25 angico (Guest)
on 2008-11-18 13:36
(Received via mailing list)
Em Ter, 2008-11-18 às 21:03 +0900, Peter Szinek 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!
Dbf12550cae38b163a584a826fc6d9b5?d=identicon&s=25 angico (Guest)
on 2008-11-18 13:45
(Received via mailing list)
Em Ter, 2008-11-18 às 21:29 +0900, Jan Pilz 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!
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2008-11-18 13:51
(Received via mailing list)
> 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
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2008-11-18 13:51
(Received via mailing list)
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
Dbf12550cae38b163a584a826fc6d9b5?d=identicon&s=25 angico (Guest)
on 2008-11-18 13:58
(Received via mailing list)
Em Ter, 2008-11-18 às 21:46 +0900, Peter Szinek 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!
Dbf12550cae38b163a584a826fc6d9b5?d=identicon&s=25 angico (Guest)
on 2008-11-18 14:13
(Received via mailing list)
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!
621080472679266b8e9b81aff4800398?d=identicon&s=25 Saji N Hameed (Guest)
on 2008-11-18 14:21
(Received via mailing list)
* angico <angico@angico.org> [2008-11-18 22:08:58 +0900]:

> 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

> skype: an.gi.co
> ------
>
>
>
>

--
Saji N. Hameed

APEC Climate Center                  +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705      saji@apcc21.net
KOREA
This topic is locked and can not be replied to.