Skip to content

Instantly share code, notes, and snippets.

@tfrisk-old
Created February 6, 2015 08:03
Show Gist options
  • Save tfrisk-old/6a60b968c8b9780d987b to your computer and use it in GitHub Desktop.
Save tfrisk-old/6a60b968c8b9780d987b to your computer and use it in GitHub Desktop.
How to setup local postgres database for local Rails project
# I have to look this up every time so it's about time to write it down
# Source: https://stackoverflow.com/questions/19953653/how-to-set-up-postgres-database-for-local-rails-project
Login to postgresql prompt as the postgres user
# sudo su postgres -c psql
Create a postgresql user for your project
=# create user username with password 'password';
Setup your postgres user with the same name and password as your Ubuntu user and make him a postgres superuser
=# alter user username superuser;
Create the development and test databases
=# create database projectname_development;
=# create database projectname_test;
Give permissions to the user on the databases
=# grant all privileges on database projectname_development to username;
=# grant all privileges on database projectname_test to username;
To end the postgresql session type \q
Update password for the user
=# alter user username with password ‘new password’;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment