Change password of postgres account in Postgres
When installing Postgres on Windows, there is some default account created for user to login. One of them is postgres, but we often don;t know what's the password for this account when we first login using this account. We need to change the password for this account. How to change it?
Step 1. Modify the pg_hba.conffile
Go to the /data/ and open the pg_hba.conf.
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
For the method, the default is md5 which means it needs a password, so here we need to change the method to trust and then save it
host all all 127.0.0.1/32 trust
This means user can login without any password.
Step 2 . Login to Postgres server
Once the above is done, we can login to Postgres using psql command(Postgres client) to login:
psql -U postgres
Then we can enter the psql command line mode, now we can execute the below SQL command:
ALTER USER postgres WITH PASSWORD '';
Once the above is executed, the password is changed
Step 3. Revert the login method
Now modify the pg_hba.conf file and change the method back to md5 and save it and restart the Postgres service.
Now you can using the new password to login now.
By clicking the "Mark as important" button, this article will be put to your important article list which you can find in "Amin->Article important list". Later when you want reread this article, it's easier for you to find it by checking the "Article important list".
::Comment Zone (Total 0 comment)
:: Other versions
No other versions available yet.
:: Recent articles
- HeartBleed: OpenBSD now starts to clean up OpenSSL
- HeartBleed: Should C be blamed for the HeartBleed bug?
- HeartBleed: Inside the heart, what happens to a normal WEB user?
- Learning Python as your first programming language
- PHP Apache MySQL Set-up Note
- Hey, you may be happy to know these mottos about programming languages
- Tips for a better first-time hackathon experience
- <=> operator in MySQL
- Why does LinkedIn migrate to NodeJS from Ruby?
- more ►
:: Most read
- Cross Browser HTML5 Drag and Drop
- Sony is to release PlayStation4 in 2015
- GCC is compiled with C++ compiler
- TIOBE : C overtakes Java as the No.1 programming language
- 5 Free Open Source Chat Applications For Developers
- Which programming language should I learn first?
- Disposable Email address
- Why PHP is (so much) better than Ruby?
- Is Ubuntu becoming a big name in enterprise Linux servers?
- Great code is written twice (or more)
- more ►
:: Find us