Sign up Sign in Samples Blog contact support
Database Configuration

To configure your database, you will need to edit the config/database.yml file.

 

The defaults are set to use MySQL, but Wagn has been well tested in PostgreSQL (including full-text search), and there are rumors that it functions properly with SQLite too.

 

This is a standard Ruby-on-Rails setup, so if you encounter problems with database configuration and can't find answers here, considering broadening your search beyond "wagn database installation" to "rails database installation".

 

Engine-Specific help:

PostgreSQL

Install the package:

$ sudo apt-get install postgresql

 

Try to install the gem:

$ sudo apt-get install libpq-dev

$ sudo gem install pg

 

For more advanced options follow the guide on the Debian Wiki https://wiki.debian.org/PostgreSql or the Arch Linux Wiki https://wiki.archlinux.org/index.php/PostgreSQL

 

Some actions require:

Becoming the 'postgres' user

(typically the "root" user for postgresql)

 

Several sections have instructions stating "become the postgres user". Commands that should be run as the postgres user are prefixed by [postgres]$ in this article.

 

To become the postgres user execute the following:

$ sudo -i -u postgres

 

If you like using root to get a shell as the postgres user:

$ su - postgres

The postgres user will automatically be created by installing PostgreSQL.

 

Now create the user and the database:

createuser -d wagn-user -P

(enter your database user password twice)

createdb -O wagn-user wagn-database

Postgres hints: you may have to mess with authentication config in pg_hba.conf to connect. Default configs have local identity based setting for authentication, and none for remote.

 

Example database.yml for Production

# MySQL.  Versions 4.1 and 5.0 are recommended.

# Be sure to use new-style password hashing:

#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: test_development

  pool: 5

  username: root

  password:

  host: localhost

 

# Warning: The database defined as "test" will be erased and

# re-generated from your development database when you run "rake".

# Do not set this db to the same as development or production.

test: &test

  adapter: mysql2

  encoding: utf8

  reconnect: false

  database: test_test

  pool: 5

  username: root

  password:

  host: localhost

 

cucumber: *test

 

production:

  adapter: postgresql

  encoding: utf8

  reconnect: false

  database: wagn-database

  pool: 5

  username: wagn-user

  password: 12345678

  host: localhost

 

MySQL

Install the package:

# apt-get install mysql2

 

Try to install the gem

$ gem install mysql2

 

If you're planning on using the mysql2 gem for your application then you'll want to install the libmysqlclient-dev package before you do that. Without it, you'll get an error when the gem tries to compile its native extensions:

 

Building native extensions.  This could take a while...

ERROR:  Error installing mysql2:

    ERROR: Failed to build gem native extension.

 

    /home/ryan/.rubies/ruby-2.2.0/bin/ruby extconf.rb

checking for ruby/thread.h... yes

checking for rb_thread_call_without_gvl() in ruby/thread.h... yes

checking for rb_thread_blocking_region()... yes

checking for rb_wait_for_single_fd()... yes

checking for rb_hash_dup()... yes

checking for rb_intern3()... yes

checking for mysql_query() in -lmysqlclient... no

checking for main() in -lm... yes

checking for mysql_query() in -lmysqlclient... no

checking for main() in -lz... yes

checking for mysql_query() in -lmysqlclient... no

checking for main() in -lsocket... no

checking for mysql_query() in -lmysqlclient... no

checking for main() in -lnsl... yes

checking for mysql_query() in -lmysqlclient... no

checking for main() in -lmygcc... no

checking for mysql_query() in -lmysqlclient... no

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers.  Check the mkmf.log file for more details.  You may

need configuration options.

 

Install this package using:

$ sudo apt-get install libmysqlclient-dev

 

If you are running mysql and rake complains about not being able to find your mysql.sock file, you will need to add "socket: " to each of the database definitions

Example database.yml for Development

development:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_development
username: wagn
password: hi_im_a_password_right_up_in_here
host: localhost

 

test:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_test
username: wagn
password: woo_hoo_password
host: localhost

production:
adapter: mysql
socket: /var/mysql/mysql.sock
database: wagn_production
username: wagn
password: password_ahoy
host: localhost