Reply to comment

Connexion problem after changing posgres user password

I juste spent 4 hours trying to figure out what was happening and why I was unable to connect to my posgresql server using the postgres user just after changing his password.

I just write down here how I solved the problem in case it happen again to me or to one of the visitor of this website.

====== here is the procedure ============

1- First a remenber on how to change a postgresql user password using the command line tool. Open up a "Terminal" or any othe shell prompt:

a)become the “postgres” system user using command line:

$: sudo su postgres

b) connect to the local server using

 $: psql 

c) Type the “\password” meta command of psql. You will be asked to enter a password and confirm it.

postgres=# \password
Enter new password:
Enter it again:

2-The problem!!!

In my case I don't know why, but while changing the password postgresql has set up the validity of the new password to the exact time on what I did the change. Meaning that few second later I'm no more allow to use the password because it has already expired! so how to see the validity of your password has change and if yes how to change that validity to something more suitable?

a) To see password validity type at the command line prompt:

$: sudo -u postgres psql -x -c "select * from pg_user where usename='postgres'"

b)To remove a validity limit, type:

$: sudo -u postgres psql -x -c "ALTER USER postgres VALID UNTIL 'infinity'"

Et voila! the work is done! you can go back to your work with a smile! :-D


  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
8 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.