What is the default password for Postgres
WindowsPostgresqlWindows Problem Overview
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:
Windows Solutions
Solution 1 - Windows
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:
- Edit
pg_hba.conf
, setting the auth mode totrust
instead of the defaultmd5
- In the Services control panel restart the PostgreSQL service
- Connect with
psql
or PgAdmin or whatever ALTER USER postgres PASSWORD 'mynewpassword';
- Edit
pg_hba.conf
again and set the auth mode back tomd5
- Restart PostgreSQL again
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
.
Solution 2 - Windows
[LINUX]
might work for windows too
After installing postgres follow following steps in order to setup password for default system account of Linux execute following in terminal:
user:~$ sudo -i -u postgres
postgres@user:~$ psql
after executing above two commands you will get into postgres shell
Execute this query in postgres shell:
postgres=# ALTER USER postgres PASSWORD 'mynewpassword';
your new password is 'mynewpassword'
without quotes and now you can connect with external GUI tools like DBeaver
Solution 3 - Windows
On initialisation you can access the DB as:
Username: postgres
Password: postgres
Solution 4 - Windows
Through trial and error I found that the password for Postgre SQL 10 for the username postgres is "admin". I kept typing in different password until I reached that password. I am using pgAdmin 4 to test out my SQL Statements, POSTGRE SQL 10 is the first server connection set up using localhost.
Solution 5 - Windows
go to control >> computer management >> Locaol users and group >> users >> right click on openpgsvc >> set password. after that now you can access with this password on openpgsvc
Solution 6 - Windows
step1: Go to control panel
Step2: Click on Administrative Tools
Step3: Click on Computer Management
Step4: There under "Local Users and Groups" Double click on user
Step:5: then right click on postgres and you can set password
refer this below image