Learning Rails

April 21, 2006

Can’t Make MySQL Table for Rails

Filed under: Gnarly Bugs, Rails — joelg @ 2:00 pm

I ran into my first “bug” the stopped me cold. I define a “bug” as anything that prevents me from moving forward, whether it’s code, configuration, poor interface, etc. It’s a practical definition based upon the fact that I’m programming to solve a problem, to get something done, and if I can’t, then I need to fix it so I can.

The problem was permissions on the MySQL database when following along on pg. 55 of Agile Web Development with Rails : A Pragmatic Guide. It’s the first exercise of hooking up a database to Rails.

As part of building the MySQL table, the exercise has you execute the following line:

depot> mysql depot_development

Up to this point in the exercise, connecting to the database was done with the username “root” and no password. Everything worked fine. But executing the above line caused the following error.

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

Can’t finish creating the database.  Rats!

The Solution

Long story short, the solution was found in the MySQL Error Log.  In it, I kept on seeing citations that had “port:3306″ in it.

Instead of trying to connect and build the database from the command line, like it’s illustrated in the book, I decided to use MySQL-Front to connect to the database.   But I still could not.
Now, the server that ships with Rails, WEBrick, apparently is on port 3000.  I tried that port in MySQL-Front.  No luck.

So, I tried using port 3306.  It connected just fine!

Now, I haven’t actually tried to manipulate the table in MySQL-front, or Rails, just yet because I’ve run out of timing trying to solve this problem, but I think I solved the problem.

2 Comments »

  1. I seriously dig that book, but I think version control of the database schema is a bit of overkill for something as simple as apps I’m working with. Honestly, while knowing SQL is handy, I’m a big fan of the actual MySQL font-end stuff (MySQL Admin and MySQL Query Browser) from http://www.MySQL.com for the heavy lifting.

    And yes, the inital MySQL setup kinda sucks, as I’m on OSX and apaprently MySQL is bound to a different adaptor than my Ethernet connection, so I ended up having to crack my way in from the command-line before I could even start loading data in.

    Comment by Paul Sweeney — January 29, 2007 @ 1:02 am

  2. Hi. I am running into the same problem. How did you change WEBrick’s port to 3306?
    Thanks a lot!
    marisio

    Comment by marisio — February 21, 2007 @ 12:01 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress