SQL and Rails

Which OS are you using, which SQL DataBase are you using and version?

Well getting MySQL installed is paramount to getting things started.

I'm not a Gentoo user, but I use Fedora, so things should be similar
enough to get you started.

For MySQL Install, I use the yum package manager (yum install mysql*)

There are other package managers as well, apt-get, rpm's, etc, if yum
isn't your thing, let me know what works for you, maybe one of the
others on the list can chime in on getting you setup.

you can also check to see if it's installed.

$ which mysql

or

$ yum list mysql*

If that returns something like /usr/bin/mysql then you're in business.

You might want to check mysql.com they have a lot of good install
information as well.

I've been thinking about setting up a Gentoo box. It work well for you?

Matt

Excellent, with any luck we can get your db set up

you will need to make sure that the mysqld is running. On my system, I
run /etc/init.d/mysqld start

It basically runs through a script that makes a call
to /usr/bin/mysql-safe (or something like that) and sets up a mysqld
server daemon.

After the daemon is up and running,

$mysql -uroot

This will start your mysql session as root. Might have to use -p and a
password, but I believe that mysql defaults to a root user with no
password.

then you will get a mysql prompt.
then create 3 databases.
You can choose whatever you want, but by convention, the name of the
project followed by _development, _production and _test

mysql > create database db_development;
mysql > create database db_production;
mysql > create database db_test;

This will create the 3 databases that the book probably references. ( I
haven't read that one, but the procedure should be the same)

then

mysql > grant all on db_development.* to 'username'@'localhost'
identified by 'yourpassword';

mysql > grant all on db_test.* to 'username'@'localhost' identified by
'yourpassword';

you can do the same thing for the production db, but 2 things to
mentions. 1) while playing / developing, you may never use the
production db. 2) when using the production env, you want to cinch down
the permissions, so 'grant all' wouldn't be appropriate. While
testing/developing, I grant all to my self on production, but never on
something that leaves my machine.

Also, 'username' is any name you choose
and 'yourpassword' is any password you choose.

All the while this has been as a root mysql user, so exit out of mysql
and log back in as such:

$ mysql -u username -p
enter password:

this will ask for your password you just set up.

mysql > show databases;

should display the 3 new databases we just setup

All should be good.

OK, I think that covers getting you set up from the command line.

I forgot that there are some GUI tools (mysql-admin, and another one..)
that makes it easier for some, but I've been command-line for so long,
that I forget about those things.

So let me know if this gets you setup with the DB

Matt

in your database.yml file, there is a section for development, test, and
production

in each section add the following:

socket: /var/lib/mysql/mysql.sock

That is the path that fedora uses, I suspect that it is the same on
Gentoo. There should be a way to find where the socket is located, but
I'm at a loss at the moment, so try the above first, and cross your
fingers.

Matt

Not for sure on what to say. Try to restart the mysqld daemon. Also
try the mysql forums, they might know more.

Google might get you over this hump too, but if I understand MySQL
correctly, a mysql.sock file gets created every time the daemon
re-starts, so I would try that first.

Good luck, you're almost there.

Matt

Sorry, late to the thread, but --

prompt% mysqld --print-defaults
mysqld would have been started with the following arguments:
--port=3306 --socket=/tmp/mysql.sock --default-character-set=utf8
--character_set_server=utf8 --datadir=/usr/local/mysql/data .........

FWIW,