We are going to use the ALTER USER command to change a user’s attribute such as name and password.

To change username:

ALTER USER user_name RENAME TO new_name

To change user password:

ALTER USER user_name WITH PASSWORD 'strongpassword';

Note that using the ALTER USER statement will transfer the password to the server in plaintext. In addition, the plaintext password may be logged in the psql’s command history or the server log.


In psql, run the command \password then enter your new password you want for that user and then confirm it.

If that does not work, reconfigure authentication. Edit the file pg_hba.conf (path might be like this: /etc/postgresql/9.3/main/pg_hba.conf) and change:

    local   all             all                                     peer

to:

    local   all             all                                     md5

Need a good GUI tool for PostgreSQL? TablePlus is a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server, Redis and more.


Download TablePlus here. It’s free anyway!

TablePlus GUI Tool PostgreSQL