database.yml is the database configuration file. It contains the required information for rails to connect to your database.
By default it contains three configurations: production, development, and test.
The data is formatted in YAML, so watch for tabs, as they are significant.
See examples here: http://www.jumbabox.com/2008/06/ruby-on-rails-database-setup-tutorial/
Since YAML, by design, is parsed conveniently into native data types, traversing your configuration data is as easy as accessing any other hash or array.
All you need to know is that the parsed data can be found at ActiveRecord::Base.configurations.
<pre>
Check that the socket exists, and if not, check your mysql configuration. Next make sure your database config file(database.yml) points to the correct file.
socket: /path/to/mysql.sock
for example, under Gentoo, the socket is likely at /var/run/mysqld/mysqld.sock. Try locate mysqld.sock if you’re not sure where yours is.
If you’d rather use TCP/IP sockets instead of Unix sockets, change the server directive to “127.0.0.1” instead of “localhost”.
If you get a database connection error like:
Access denied for user 'root'@'localhost' (using password: NO)
This may happen even though you’ve set the appropriate db settings in database.yml, they can be verified using the console, and you can log in with ‘mysql’ using the same username as password.
This can occur because you’ve made a change to the file while the web server was running, because the contents of database.yml get cached. Make sure that you restart your web server once making changes to database.yml so that the new settings are loaded.