How to change the password of the postgres user on centos

The password of the PostgreSQL database default user postgres

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

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

 Remarks:

There are two postgres accounts, one for the database and one for the linux system.

Step 1: Log in to PostgreSQL

#sudo -u postgres psql

 

Step 2: Modify the password to log in to PostgreSQL

#ALTER USER postgres WITH PASSWORD 'xxxxxxxxxxx';
ALTER ROLE

Note:

密码postgres要用引号引起来,命令最后有分号

  • 1
  • 2

Step 3: Exit the PostgreSQL client

1

#\q

 

back to the top


 Modify the password of the postgres user on the linux system

PostgreSQL will create a default linux user postgres, the method to modify the user's password is as follows:

Step 1: Delete the password of user postgres
1

1

#sudo passwd -d postgres

  

Step 2: Set the password of user postgres
1

1

#sudo -u postgres passwd

  

The system prompts for a new password
 

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

Guess you like

Origin blog.csdn.net/qq_42533216/article/details/112866033