Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

password for postgres

Tags:

In the short version of postgres' installing it tell me to do the following

./configure gmake su gmake install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test 

Now I created the postgres user, but it sometimes asks for my credentials for that user. Is there a default password for the postgres user? Why do I even need to make another user?

like image 231
Doboy Avatar asked Mar 23 '12 00:03

Doboy


People also ask

What is default password for postgres?

For most systems, the default Postgres user is postgres and a password is not required for authentication.

What is sudo password for postgres?

By all means read the linked answer, sudo passwd postgres should not be used, instead run sudo -u postgres psql postgres and enter \password postgres .

What is the default password for postgres Windows?

There is no 'default' PostgreSQL username/password. The credentials supplied in the install process are also used to make these accounts. If you know that username and password you might be able to use the same password to log into PostgreSQL.


2 Answers

What's the default superuser username/password for postgres after a new install?:

CAUTION The answer about changing the UNIX password for "postgres" through "$ sudo passwd postgres" is not preferred, and can even be DANGEROUS!

This is why: By default, the UNIX account "postgres" is locked, which means it cannot be logged in using a password. If you use "sudo passwd postgres", the account is immediately unlocked. Worse, if you set the password to something weak, like "postgres", then you are exposed to a great security danger. For example, there are a number of bots out there trying the username/password combo "postgres/postgres" to log into your UNIX system.

What you should do is follow Chris James's answer:

sudo -u postgres psql postgres  # \password postgres  Enter new password:  

To explain it a little bit...

like image 185
Doboy Avatar answered Oct 24 '22 02:10

Doboy


Set the default password in the .pgpass file. If the server does not save the password, it is because it is not set in the .pgpass file, or the permissions are open and the file is therefore ignored.

Read more about the password file here.

Also, be sure to check the permissions: on *nix systems the permissions on .pgpass must disallow any access to world or group; achieve this by the command chmod 0600 ~/.pgpass. If the permissions are less strict than this, the file will be ignored.

Have you tried logging-in using PGAdmin? You can save the password there, and modify the pgpass file.

like image 38
MAbraham1 Avatar answered Oct 24 '22 01:10

MAbraham1