I wanted to start a discussion on MySQL issues that people may have
when trying to setup a local version of their Rails application.
Common Pitfalls
1. You installed mysql through a 3rd party installer (MySQL for MacOSX
dmg, or port install mysql) and now Rails can't find your database.
You need to provide Rails with the path to MySQL's socket
(mysqld.sock). You can find this value by looking at the mysql.conf
file, which should be in init.d (linux if installed via yum), or added
automatically when you did an RPM or Binary install of mysql, just do
a search of your machine for it. I digress, the socket location is
important so Rails can connect to the DB server.
database.yml (/app_root/Configuration/database.yml)
Sample Configuration
development:
host: 127.0.0.1
adapter: mysql
database: railsclass
port: 3306
username: root
password:
socket: /var/run/mysqld/mysqld.sock
----
(*Note: socket: /tmp/mysqld.sock is the typical socket location,
depending on your security needs, or preferences this can be moved to
a location of your choosing.)
Please note above, you don't ever want to run MySQL as root, this
means 1 oops and your database has granted root level access to your
system. It is a best practice to create layers of security in your
applications, one way of doing that is to create different users who
can accomplish different tasks , eg. godmode, has full read, write, db
create privileges while average_system_user may only have read access
to the database.
Please take a look at MySQL installation notes at
http://dev.mysql.com/doc/refman/5.1/en/installing.html. You will see
the best practices for setting everything up from scratch, as well as
interesting optional preferences.
Good Luck,
Scott Haines