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`

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.