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 root@localhost"

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

joey

hi!

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

>>User.find(:first)

returns : "access denied for root@localhost"

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

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

Craig White wrote:

Marcelo de Moraes Serpa 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 Boy <rails-mailing-list@andreas-s.net

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 White 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?

Posted via http://www.ruby-forum.com/.

Marcelo de Moraes Serpa 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 Boy <rails-mailing-list@andreas-s.net

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:

Posted via http://www.ruby-forum.com/.

Craig White 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?

Craig White wrote:

Craig White 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.

Craig White 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.


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

Craig White wrote:

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.

Craig White 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!

Posted via http://www.ruby-forum.com/.

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!