postgres password change

1. Modify the password of the default user postgres in the PostgreSQL database
The PostgreSQL database creates a postgres user as the database administrator. The password is random, so the password needs to be changed as follows:

Step 1: Log in to PostgreSQL

1
sudo -u postgres psql
Step 2: Modify the password for logging in to PostgreSQL

1
ALTER USER postgres WITH PASSWORD 'postgres';
Note:

The password postgres should be enclosed in quotes
command with a semicolon at the end
Step 3: Exit the PostgreSQL client

\q
back to the top
2. Modify the password of the postgres user in the linux system
PostgreSQL will create a default linux user postgres, and the method to modify the user's password is as follows:

Step 1: Delete the password of the user postgres

1
sudo  passwd -d postgres
Step 2: Set the password of the user postgres

1
sudo -u postgres passwd
The system prompts for a new password

1
2
3
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324907706&siteId=291194637