0

I'm having a hard time getting Ruby to connect to mySQL. I can get MYSQL to connect using the mySQL workbench, so that's good. Here is the error I'm getting when I try to run DBConsole.

W:\testMySQL>rails dbconsole
Enter password: ********
ERROR 1045 (28000): Access denied for user 'coffeetowndev'@'localhost' (using pa
ssword: YES)

I'm running on a Database on a GoDaddy account, so I'm not able to grant all privledges to that user. I called godaddy, and they swore their 'RoR' department was able to connect using my settings. Speaking of this, here is the database.yml file.

development:
 adapter: mysql
 encoding: utf8
 reconnect: false
 port: 3306
 database: coffeetowndev
 pool: 5
 username: coffeetowndev
 password: ********
 hostname: coffeetowndev.db.5850247.hostedresource.com

on a related/unrelated note, I'm not able to get mySQL2 gem to install, so I'm using the mySQL one.

edit: entire database.yml file

development:
 adapter: mysql
 encoding: utf8
 reconnect: false
 port: 3306
 database: coffeetowndev
 pool: 5
 username: coffeetowndev
 password: ********
 hostname: coffeetowndev.db.5850247.hostedresource.com

test:
 adapter: mysql
 encoding: utf8
 reconnect: false
 port: 3306
 database: coffeetowntest
 pool: 5
 username: coffeetowntest
 password: ********
 hostname: coffeetowntest.db.5850247.hostedresource.com


production:
 adapter: mysql
 encoding: utf8
 reconnect: false
 port: 3306
 database: coffeetown
 pool: 5
 username: coffeetown
 password: ********
 hostname: coffeetown.db.5850247.hostedresource.com
1
  • Is there anymore info you want to see? and files? error pages? non-error pages? Also, it appears my call for help was edited out. Is this more of a demanding help kinda-place? Commented May 9, 2011 at 3:29

2 Answers 2

0

Are you using the production setting when you deploy to godaddy, instead of the development one? I'm not experienced with using godaddy for hosting Rails apps, but it's possible they configure all hosted applications to default to the production environment (many rails hosts do). Therefore, it may not be using the username/password combination you're expecting if it's using a different environment.

You may also want to try testing your credentials by coding up a quick and dirty PHP test script, something like this:

$con = mysql_connect("coffeetowndev.db.5850247.hostedresource.com","coffeetowndev","******");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
echo 'Connected successfully';

mysql_close($con);

Also, above it says it's failing but it's trying to use user 'coffeetowndev'@'localhost'. You must ensure that you granted permissions to that user using somethign like this:

grant select,insert,update,delete on coffeetowndev.* to 'coffeetowndev'@'localhost' identified by ********
Sign up to request clarification or add additional context in comments.

18 Comments

oh, I'm not using godaddy for the rails ap, just for the MySQL DB. I plan to push this to heroku, but keep the DB where it is? or is this a horrible idea?
Ah. Something is amiss then. It's trying to use a local database. Wherever you're running the rails app, it's trying to hook up to a database locally, and is not trying to connect out to coffeetowndev.db.5850247.hostedresource.com from a remote host. Otherwise, mysql's error message would be: ERROR 1045 (28000): Access denied for user 'coffeetowndev'@'123.123.123.1' (using pa ssword: YES), where 123.123.123.1 is the remote host on which the rails app is running.
but it knows that the user is 'coffeetowndev' when I enter the password, if I enter it with no password, I get this error: ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'coffeetowndev' So, it's hitting the correct DB, bacuse the localhost DB has no info in it whatsoever.
As far as being a bad idea, the paranoid side of me says yes. However, many hosts leave mysql open to the internet by default (from a port perspective). Then, you need to be absolutely sure that you've locked down the user permissions as tight as you can. You'll probably have to use % as a wildcard in the host segment, as the remote IP will likely change while hosting with Heroku. So, you'll need something like this: grant ... on ... to 'coffeetowndev'@'%'. My gut reaction though, would be to just have Heroku host your database, rather than trying to host it with Godaddy.
Try replacing hostname: with host: in your database.yml file. Can you paste your entire database.yml file? What version of rails are you on?
|
0

Do you have PHPMyAdmin installed on your SQL server? Typically whenever I create a new users, I'll go through PHPMyAdmin and set up the user with Grant access on the database I'm working with on RoR. Your database.yml looks fine, issue is on the SQL side.

4 Comments

I do, but I couldn't do a select on the mySQL.users table. I didn't have permission to even do that. I tried to do a grant all for the user 'coffeetowndev' but that error'd out.
What user were you logged in as when trying to do the grant?
coffeetowndev. I don't have root user capability from godaddy. bah. (and of course that isn't going to work. I see that now)
You don't actually need root, you just need with grant option specified on your account. I would expect that you could configure this, or at least configure additional users, from their control panel.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.