Skip to content

Instantly share code, notes, and snippets.

@p1nox
Last active November 30, 2022 10:28
Show Gist options
  • Save p1nox/6101460 to your computer and use it in GitHub Desktop.
Save p1nox/6101460 to your computer and use it in GitHub Desktop.
PostgreSQL configuration without password on Mac for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

Go to Postgre Download Site

Install Postgre gem

/Gemfile

gem 'pg'

Configuration

  1. Edit postgre configuration file:

     sudo nano /Library/PostgreSQL/9.3/data/pg_hba.conf
    
  2. Change all configuration access to:

     # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
     # "local" is for Unix domain socket connections only
     local   all             all                                     trust
     # IPv4 local connections:
     host    all             all             127.0.0.1/32            trust
     # IPv6 local connections:
     host    all             all             ::1/128                 trust
    
  3. Restart postgre server

     sudo su - postgres
     cd /bin
     ./pg_ctl -D /Library/PostgreSQL/9.3/data stop 
     ./pg_ctl -D /Library/PostgreSQL/9.3/data start
    
  4. Set your database.yml Rails file:

     development:
       adapter: postgresql
       username: postgres
       database: DATABASE_NAME_development
       host: localhost
       pool: 5
       encoding: unicode
    
     test:
       adapter: postgresql
       username: postgres
       host: localhost
       database: DATABASE_NAME_test
       pool: 5
       encoding: unicode
    
  5. Enjoy :)

@dieg0
Copy link

dieg0 commented Sep 14, 2014

I installed Lunchy for finding homebrew's postgresql
Check it here:
http://www.moncefbelyamani.com/how-to-install-postgresql-on-a-mac-with-homebrew-and-lunchy/

@p1nox
Copy link
Author

p1nox commented May 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment