No db connection in console

hi!

i created a db with one table “users” with one record, then run ruby
script/console

User.find(:first)

returns : “access denied for [email protected]

why is that? i created the table and record inside mysql through the
same user and password in database.yml.

joey

On Wed, 2008-07-30 at 04:57 +0200, Joey B. wrote:

same user and password in database.yml.


sounds like when you connected to mysql from command line, it used
sockets but your setup in database.yml is using port 3306 which actually
is different.

You probably want to figure out where the socket is, enter that in
database.yml and comment out the port…

stuff removed for clarity…

ps aux|grep mysql.sock

root 8017 0.0 0.0 4524 224 pts/1 S Jul27
0:00 /bin/sh /usr/bin/mysqld_safe --socket=/var/lib/mysql/mysql.sock

thus I would want to add to database.yml…
socket: /var/lib/mysql/mysql.sock

Craig

Check you password in database.yml. Also, make sure you actually have a
root
user in mysql.

On Tue, Jul 29, 2008 at 11:57 PM, Joey B.
<[email protected]

Marcelo de Moraes S. wrote:

Check you password in database.yml. Also, make sure you actually have a
root
user in mysql.

On Tue, Jul 29, 2008 at 11:57 PM, Joey B.
<[email protected]

hello!

thank you. i’m 101% about the password, and i do have root account in
mysql. i actually created another account with same user as the db.
hoping rails was expecting that. but…apparently…i’m wrong… :frowning:

Dude, it’s already running.

You’re specifying the wrong username or password, or that user does
not have correct permissions to access the database.

Craig W. wrote:

On Wed, 2008-07-30 at 04:57 +0200, Joey B. wrote:

same user and password in database.yml.


sounds like when you connected to mysql from command line, it used
sockets but your setup in database.yml is using port 3306 which actually
is different.

You probably want to figure out where the socket is, enter that in
database.yml and comment out the port…

stuff removed for clarity…

ps aux|grep mysql.sock

root 8017 0.0 0.0 4524 224 pts/1 S Jul27
0:00 /bin/sh /usr/bin/mysqld_safe --socket=/var/lib/mysql/mysql.sock

thus I would want to add to database.yml…
socket: /var/lib/mysql/mysql.sock

Craig

hi!

how do you do the same with windows?

On Wed, 2008-07-30 at 05:30 +0200, Joey B. wrote:

hi!

how do you do the same with windows?


Oh - Windows…don’t use sockets

Can you connect from command line like…

mysql YOUR_DATA_BASE -Uroot -p

?

Craig

Craig W. wrote:

On Wed, 2008-07-30 at 05:30 +0200, Joey B. wrote:

hi!

how do you do the same with windows?


Oh - Windows…don’t use sockets

Can you connect from command line like…

mysql YOUR_DATA_BASE -Uroot -p

?

Craig

yes. i can connect.

ty!

Craig W. wrote:

On Wed, 2008-07-30 at 05:45 +0200, Joey B. wrote:

mysql YOUR_DATA_BASE -Uroot -p

?

Craig

yes. i can connect.


then make sure you database.yml does not have any tabs for whitespace
and that none of the entries have any spaces after them.

Craig

thank you craig. indeed there are whitespaces on the database.yml file.
i trusted the database.yml file that come from open source rails-based
app.

good day!

On Wed, 2008-07-30 at 05:45 +0200, Joey B. wrote:

mysql YOUR_DATA_BASE -Uroot -p

?

Craig

yes. i can connect.


then make sure you database.yml does not have any tabs for whitespace
and that none of the entries have any spaces after them.

Craig

Rails doesn’t expect anything, it only passes the user and password as
you
write them in database.yml.

So, if this user doesn’t exist in mysql, it won’t connect. If the
password
doesn’t match the correct one it won’t connect also (obviously), if the
user
doesn’t have the perms to read this database, it will return an not
authorized message or something in the lines.

On Wed, Jul 30, 2008 at 12:33 AM, Joey B.
<[email protected]

Hi joey

  The problem is its not getting mysql path with that use name & 

password…Do onething while creating project use following instruction
rails project_name -d mysql
It will create database.yml file with mysql path…

2008/7/30, Joey B. [email protected]:

2008/7/30, Craig W. [email protected]:

babu nair wrote:

Hi joey

  The problem is its not getting mysql path with that use name & 

password…Do onething while creating project use following instruction
rails project_name -d mysql
It will create database.yml file with mysql path…

hi!

that’s what i did. i generate a new app and copied the database.yml file
over the problematic one. that fixed it.

thank you so much guys!

2008/7/30, Joey B. [email protected]:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs