Last Updated: February 25, 2016
·
2.797K
· fernandoalmeida

Usando Postgres local sem senha

Em ambiente de desenvolvimento podemos facilitar o uso do Postgres permitindo login sem senha.

Para isto basta substituir o conteúdo do arquivo /etc/postgresql/POSTGRES_VERSION/main/pg_hba.conf por

local  all  all                trust
host   all  all  127.0.0.1/32  trust
host   all  all  ::1/128       trust

Depois de reiniciar o serviço já será permitida conexão, tanto local quanto via rede/VM, com qualquer usuário (inclusive o postgres) sem senha.

Para testar execute o comando psql -U postgres.

Referência:

http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html