I have just install Postgres 9.3 on Windows 7. The installation completed successfully. It has never asked me to provide the password for postgres user.
The service postgresql-x64-9.3 is up and running. However, I cannot connect: I do not not know the password. I've found the following answer, but it did not help:
similar question on Ubuntu
The default username and password are "postgres" and "password". Also when you set a superuser password during PostgreSQL installation, the password may be set up to this "superuser password" value (at least happened for me with the windows-installer installation). This is not the default.
sudo -u postgres psql postgres # \password postgres Enter new password: To explain it a little bit... 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 .
WARNING: trust
means exactly that. Anyone who can connect to the PostgreSQL server can control it. If you set trust
mode that allows superusers like user postgres
(or all
users) to connect, they get total control of your PostgreSQL and can probably run shell commands too. You should usually only use it to change the password then restore the configuration back to the auth mode you were using before.
If you used an unattended installer script, the password will be in the script or associated config file.
Otherwise, treat it the same as if you lost/forgot the password rather than never knowing it:
pg_hba.conf
, setting the auth mode to trust
instead of the default md5
psql
or PgAdmin or whateverALTER USER postgres PASSWORD 'mynewpassword';
pg_hba.conf
again and set the auth mode back to md5
pg_hba.conf
is in your data directory. By default it'll be %PROGRAMFILES%\PostgreSQL\9.3\data
.
To edit it you'll have to use the security tab to give yourself read/write permissions (via a UAC prompt). This might require you to set yourself as the owner of the file.
On unix systems it's more secure to prepend a
local all all peer
line to pg_hba.conf
and then sudo -u postgres psql
(assuming your PostgreSQL server runs as user postgres
) to get an interactive psql
session without using a password. That way you don't have to use trust
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With