I have freshly installed postgresql 9.4 on my ubuntu 14.10 box and I have run \password
as the postgres
user and given it the password postgres
:
$> sudo -u postgres psql
=# \password
Enter new password: postgres
Enter it again: postgres
=# \q
$>
I have also updated the /etc/postgresql/9.4/main/postgresql.conf
with listen_addresses='localhost'
and restarted postgresql.
ISSUE
When I run psql -U postgres -h localhost
I am still prompted for a password.
QUESTION
What else should I try in order to prevent being prompted for a password while executing psql
commands locally?
I finally found the answer here. The issue was that I was missing the
~/.pgpass
file. So I created one with access permission600
(this is important) and added the following lines:After a restart of
postgresql
all was well :)I finally find the answer and it works fine for me.
Change postgres user’s password
PostgreSQL is provided with a default user named ‘postgres’. For this, we will use this role and change its password. Run following command to jump into postgreSQL cmd.
Enter your root/sudo password. This will take you to the psql cmd which will be prompted like
Here ‘postgres’ is the username you’re currently logged in with. Now run following command to change password.
This will prompt you to enter your new password for user ‘postgres’ and then will ask you to confirm it by reentering it. You’re done with possible solution.