How to set up Postgres database for local Rails project?

前端 未结 3 584
死守一世寂寞
死守一世寂寞 2021-01-30 09:37

I recently got a new machine and would now like to work on my projects from Github. I\'m curious as to how to properly set up the Postgres database on my local machine. I have <

3条回答
  •  被撕碎了的回忆
    2021-01-30 09:47

    I came across your question when looking for the same answer. I attempted to follow the instructions @prasad.surase gave you. The problem I found is the ppa repository is going to depreciate soon on 12.04 LTS. Instead I found this link and it really helped.

    PostgreSQL setup for Rails development in Ubuntu 12.04

    1. Install postgresql and admin tools through the package manager

      sudo apt-get install postgresql libpq-dev phppgadmin pgadmin3
      
    2. Login to postgresql prompt as the postgres user

      sudo su postgres -c psql 
      
    3. Create a postgresql user for your project

      create user username with password 'password';
      
    4. Setup your postgres user with the same name and password as your Ubuntu user and make him a postgres superuser

      alter user username superuser; 
      
    5. Create the development and test databases

      create database projectname_development;
      create database projectname_test; 
      
    6. 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’;
    

提交回复
热议问题