There is no such default password for user Postgres. The password needs to be set. Backup and Restore PostgreSQL database from PGadmin3 Console; What is the default username and password for the PostgreSQL database? Upgrading from WSFTP Server v7.5 or newer to 2018 (v8.6) on a new Operating System.
This morning I’ve been trying to connect the PostgreSQL database on my Windows 7 Professional desktop.
The default value is ‘postgres’, but sure enough I forgot what password I used when I originally installed it.
I have googled and found a post related to resetting your password. I followed the steps, but the end result is a bit different then mentioned in the post. I used--
to reset the password for my database but instead of a success message I am getting:
'System error 5 has occurred. Access is denied.'
system error. How do I avoid this error and reset the password?
AKIWEBAKIWEB
migrated from stackoverflow.comJun 15 '13 at 13:40
This question came from our site for professional and enthusiast programmers.
3 Answers
(Note: Not much of this is relevant to readers using PostgreSQL 9.2 or above from the EDB installers, which now have a greatly simplified default install using the
NETWORK SERVICE
, though you can still configure other accounts).I have used
net user postgres postgres
to reset the password for my database but instead of a success message I am getting 'System error 5 has occurred. Access is denied.'
You've reset (or tried to reset) the service account password. PostgreSQL won't run as Administrator for security reasons and the installer generally sets it up with a 'postgres' user account in PostgreSQL 9.1 and older1. On Windows you can't start a service as a user without saving the password of the user in the registry, so that's what the installer does.
If you change the password for the Windows user account
postgres
, the PostgreSQL service can no longer start. So don't do that, you'll have to fix the service configuration to store the updated password.Thankfully I think another mistake prevented you from doing that. It looks like you're probably running your command prompt without using 'Run as Administrator' on an unprivileged Windows user account or a machine with UAC, so it isn't running with the access permissions required to change the password for the
postgres
user.Before you try to change that password, make sure it's really what you want to do. What's the problem you're trying to solve here? Are you attempting to install a database update or something else that's asking for the password for the
postgres
Windows user? Most likely you're just trying to log in to the database. For that, you use the (unfortunately completely unrelated) password stored in the database its self. Since you've lost/forgotten it you'll have to reset it:
- Find your
pg_hba.conf
, usually inC:Program FilesPostgreSQL9.1datapg_hba.conf
- If necessary, set the permissions on it so that you can modify it; your user account might not be able to do so until you use the security tab in the properties dialog to give yourself that right by using an admin override. Alternately, find notepad / notepad++ in your start menu, right click, choose 'Run as administrator', then use File->Open to open
pg_hba.conf
that way. - Edit it to set the 'host' line for user 'postgres' on host '127.0.0.1/32' to 'trust'. You can add the line if it isn't there; just insert:before any other lines. (You can ignore comments, lines beginning with
#
). - Restart the PostgreSQL service from the Services control panel (start->run->
services.msc
) - connect using psql or PgAdmin-III or whatever you prefer
ALTER USER postgres PASSWORD 'postgres'
- remove the line you added to
pg_hba.conf
or change it back - restart PostgreSQL again.
See: How do I reset the postgres password for PostgreSQL on Windows?
1.9.2 now uses the
NETWORKSERVICE
account, which doesn't require a password, so this problem goes away.Community♦
Craig RingerCraig Ringer
You need to distinguish between your system (Windows) user called 'postgres' and the database user with the same name.
Find your pg_hba.conf file - this controls access to the PostgreSQL server. You will need to edit it as a user with Administrator rights. Look for lines that mention user 'postgres' and temporarily set the mode to 'trust'. Restart postgresql and then you should be able to connect without a password. Reset the password, then restore the file to its original settings and restart PostgreSQL.
The manual has details on authentication methods and the pg_hba.conf file.
Richard HuxtonRichard Huxton
If anyone else encounters this problem, while also using pgAdmin, I suggest you take a look at this: http://www.homebrewandtechnology.com/blog/graphicallychangepostgresadminpassword
Lenii AleLenii Ale
Not the answer you're looking for? Browse other questions tagged postgresqlwindowspostgresql-9.1authenticationpassword-recovery or ask your own question.
I've installed PostgreSQL 9.1 and pgadmin3 on Ubuntu Server 13.10.
I configured postgresql.conf with:
listen_addresses = '*'
also I configured ph_hba.conf by changed peer connections to
md5
Plus I reset the password of postgres by:
sudo password postgres
then restarted the service with
sudo /etc/init.d/postgresql restart
after that I tried to connect to the default PostgreSQL template database:
but login failed with this error message:
then I tried to login from the pgadmin, which gave me the same error.
I've read here that it might be a password expiry dates bugPostgreSQL user can not connect to server after changing password
but I couldn't solve it coz I cannot login with psql. Does anyone now how to resolve this issue?
EDIT
ph_hba file:
Screenshot:
ShadinShadin
3 Answers
You are confusing the password for the unix user 'postgres' with the database password for the database user 'postgres'. These are not the same.
You've locked yourself out, because you enabled
md5
authentication for database user postgres
without setting a password for the database user postgres
.Add a new line to the top of
pg_hba.conf
:then restart/reload PostgreSQL and:
From the resulting prompt:
then remove the line you added to
pg_hba.conf
and restart Pg again. You can now use the password you set above to connect to PostgreSQL as the postgres
user.To learn more, read the 'client authentication' chapter of the user manual and the docs on
pg_hba.conf
.Craig RingerCraig Ringer
Try to modify the password of the database template1 using this:
pfugazzapfugazza
in your pg_hba.conf
if it does not work then try with
then restart your data baseit will work fine..if you make trust then there is no need for password if you make MD5 then it will ask password...
smn_onrockssmn_onrocks
protected by Community♦Apr 17 '18 at 5:32
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?