Tuesday, August 8, 2017

Setting Default Password for PostgreSQL in Ubuntu

# sudo -u postgres psql
could not change directory to "/root"
psql (9.1.11)
Type "help" for help.

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

There is no default password.  on most unix and linux distributions, the 
default authentication mode is set to 'ident' which means a given unix 
user X can only connect as the postgres user X.   initially, the only 
postgres user is 'postgres', so...

(assuming you're on the typical unix/linux system, you didn't say)

     $ sudo -u postgres psql

     postgres=> alter user postgres password 'apassword';
     postgres=> create user yerusername createdb createuser password 'somepass';
     postgres=> create database yerusername owner yerusername;
     postgres=> \q

Post a Comment

Dspace Demo