2

I am trying to set new password in postgreSQL.But I am getting error like below. [root@localhost ~]# sudo -u postgres psql

 could not change directory to "/root"
 Welcome to psql 8.1.23, the PostgreSQL interactive terminal.
  Type:  \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit`postgres=# \password postgres
  Query buffer is empty.
  \p: extra argument "assword" ignored
  \p: extra argument "postgres" ignored`
snirali
  • 139
  • 1
  • 4
  • 11

3 Answers3

1

This works for me. ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';

snirali
  • 139
  • 1
  • 4
  • 11
0

Try this? Link
Login to your database and use the ALTER USER Postgres WITH PASSWORD '<newpassword>'; command.

Eli Berkowitz
  • 299
  • 3
  • 12
0

Highly recommended to avoid ever using the ALTER USER Postgres WITH PASSWORD... syntax as there is a possibility whatever password you submit will be saved forever in your on disk logs.

Whenever possible, the best way to do it is through an interactive psql CL like so:

psql=# \password user_name

If you cannot do that, consider using SCRAM-SHA-256 authentication and the method described here.

Alexi Theodore
  • 1,177
  • 10
  • 16