Install PostgreSQL on Ubuntu.
sudo apt-get install postgresql libpq-dev pgadmin3 -y
Create a new Rails application with PostgreSQL.
rails new <project name> -d postgresql
If this is an old project, install the gem in Gemfile.
gem 'pg'
Create the PostgreSQL user. The username will be the same name as your project which can be found in config/database.yml.
sudo su postgres -c psql # Enters the psql console. create user "<username>" with [superuser] password "<password>"; # Outputs CREATE ROLE. \qThe superuser keyword is optional but makes things easier in development.
If you get the error "FATAL: ident authentication failed", edit /etc/postgresql/8.4/main/pg_hba.conf.
local all all identto
local all all md5
Restart PostgreSQL.
sudo service postgresql restart
Create the development and test databases through the terminal.
createdb <project name>_development -U <username> -W createdb <project name>_test -U <username> -W
No comments:
Post a Comment