Modify the password for the default user postgres of the PostgreSQL database

Source: Internet
Author: User
Tags postgresql psql postgres database

Sometimes, what if I forget the password of the default user Postgres when PostgreSQL is installed?

Linux shell command input below: sudo-u postgres psql (so that you can directly login into the Postgres, and then in the inside can be added users, change passwords and so on, are not the problem!! )

--------------------------------------------------------------------------------------------------------------- --

Modify the Default user postgres password for the PostgreSQL database (note that it is not a Linux system account)
First step: 1, PostgreSQL login (using Psql client login)
# sudo-u Postgres Psql
Among them, Sudo-u Postgres is the use of Postgres user login meaning
PostgreSQL data By default creates a Postgres database user as the administrator of the database, the password is random, so here
Set to ' Postgres '
2. Modify the PostgreSQL login password:
postgres=# ALTER USER postgres with PASSWORD ' postgres ';
postgres= #为PostgreSQL下的命令提示符
3. Exiting the PostgreSQL psql client
postgres=# \q
[code Description]

The characters before ' # ' and ' # ' are the system prompt, ' postgres=# ' is the prompt for the Psql client, and the red character is the input command (the rest of this article is also true);
[function Description]
PostgreSQL data By default will create a Postgres database user as the administrator of the database, the password is random, I need to change to the specified password, which is set to ' Postgres ' Step Two: Modify the Postgres user's password for the Linux system (the password is the same as the password for the database user postgres)
1. Remove the PostgreSQL user password
# sudo passwd-d postgres
Passwd:password expiry information changed.
Passwd-d is the meaning of emptying the specified user password
2. Set the PostgreSQL user password
PostgreSQL data creates a Linux user Postgres by default and modifies the password to ' Postgres ' through the code above (depending on
The password in the second step, as long as it is the same). Now, we can use the Postgres account on the database server to operate the database through Psql or pgadmin and so on clients.
#sudo-U postgres passwd
Enter a new UNIX password:
Re-enter the new UNIX password:
passwd: Password has been successfully updated

Modify the password for the default user postgres of the PostgreSQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.