Must. Stop. Hitting. Head. Against. Wall.

by Suw on

Ok… so I hit a brick wall with my Ruby on Rails book, Agile Web Dev. with Rails, which was that MySQL didn't behave the way the book seems to say it should. So the book implies that one should be able to issue MySQL commands using Terminal, from the directory in which the Rails app resides. So let's say you create the example Rails app 'Depot', in a directory called 'Depot'. You should be able to, from the Depot> command line be able to make MySQL do things.
Except it doesn't.
I have managed now to get MySQL to work on its own, and decided that I obviously needed to get more familiar with it so Saturday I bought Teach Yourself MySQL in 10 Minutes by Chris Newmann. To start with, it looks fine. But when I came to installing the sample database, I hit another brick wall. For starters, it's not easy to find the right files to download from the Sam's Publishing site. Took quite a bit of ferreting about to find it. And secondly, the instructions given in the book for the installation of said database simply aren't clear enough and do not work for me.
Thankfully, a friend of mine is helping me via AIM. But it's just frustrating because I'm not stupid, and I have enough of a programming background that I understand the concepts, but don't have enough experience to fix the problems that are stopping me learning, erm, how to fix such problems.
Later…
It seems that the author has made one too many assumptions, and has omitted a few vital steps in the process to get the sample tables (note: not database… they didn't say 'make this database first, then import the tables', which would have given me a clue as to why their commands didn't work) up and running. Now, you'd think that if you're writing a book for beginners you'd actually start at the beginning… This is when wikifying a book and letting people add in the missing steps would be a Really Good Thing.
UPDATE: Turns out that isn't the only issue with this book. Whilst it's a minor nit, it's annoying that some of the values stated in the book for things like column names aren't the same as those used in the sample database. So it says I need to 'SELECT id, first_name, last_name', but it turns out that there's no column called 'id', it's called 'contact_id' instead. OK, so I've learnt to find out what the column names are, so this is not holding me back, but it's poor that there isn't consistency between book and code.

Anonymous October 9, 2006 at

Are you trying to do mysql commands through the rails console, or just by running mysql from the terminal?
I've not managed to get the console to work yet (think it's something to do with the mac environment).
You might find it easier to install PhpMyAdmin on your localhost, and use that to make mysql commands instead.

Anonymous October 9, 2006 at

I'm trying to do MySQL commands through terminal, but from the Rails app folder. I think it's a path problem.
I have CocoaMySQL which is a gui for MySQL like phpMyAdmin. But to be honest, I *like* doing things from the command line right now, and I think it's better for me to do that to start with and then move on to a gui when I feel a bit more confident that I understand how the command line works.

Anonymous October 9, 2006 at

Ahh, you need to add the MySQL bin directory path to your bash_login config file.
Edit .bash_login in your home directory and edit a PATH statement so it looks something like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I got stuck here too, and then followed the instructions at here (under the 'Add MySQL to your PATH' section).
Hope that helps…

Anonymous October 9, 2006 at

Ah crap, HTML doesn't work…

Anonymous October 9, 2006 at

If you launch Terminal from Locomotive, then I think you need to include the path to /mysql/bin in Locomotive's Terminal prefs. It seems to ignore your normal environmental variables afaik…

Comments on this entry are closed.

Previous post:

Next post: