Modify postgresql password

Two methods

1. Method 1: Modify directly in the client

Open Navicat, run sql

ALTER USER postgres WITH PASSWORD 'xxx';

2. Method 2: Modify in Linux

1.1 Delete old password

sudo  passwd -d postgres

1.2 Set a new password

sudo -u postgres passwd
New password:
Retype new password:
passwd: all authentication tokens updated successfully

Change setting

3. The operation fails, any password can log in

Both of the above methods can be modified, and then do a login test on the client. If the operation fails, any password can log in, indicating that there is another configuration that has not been completed.

2.1 Modify configuration

Replace "trust" with "md5" in ${pgsql}/data/pg_hba.conf;
otherwise, any password can log in.

2.2 Restart postgresql

#su - postgres
$pg_ctl restart

Reference:
https://www.cnblogs.com/kaituorensheng/p/4735191.html
https://www.javaroad.cn/questions/113853
https://blog.csdn.net/leinminna/article/details/113249971

Guess you like

Origin blog.csdn.net/leinminna/article/details/113856887