修改 postgreSQL 數(shù)據(jù)庫中的 postgres 用戶 的密碼
postgreSQL安裝成功后,有了默認(rèn)用戶酷勺,和隨機(jī)密碼本橙, 需要修改默認(rèn)密碼
切換至 linux 系統(tǒng)用戶 postgres
su postgres啟動 psql
psql
// psql -- PostgreSQL interactive terminal
- 修改PostgreSQL登錄密碼:
postgres=# ALTER USER postgres WITH PASSWORD 'yourPostgresPassword';
//postgres=#為PostgreSQL下的命令提示符
4.退出PostgreSQL psql客戶端
postgres=# \q
修改linux系統(tǒng)的postgres用戶的密碼(密碼與數(shù)據(jù)庫用戶postgres的密碼相同)
1.刪除PostgreSQL用戶密碼
sudo passwd -d postgres
passwd: password expiry information changed.
//passwd -d 是清空指定用戶密碼的意思
2.設(shè)置PostgreSQL用戶密碼
PostgreSQL數(shù)據(jù)默認(rèn)會創(chuàng)建一個linux用戶postgres,通過上面的代碼修改密碼為'yourPostgresPassword’(這取決于第一步中的密碼鸥印,只要與其相同即可)勋功。
現(xiàn)在,我們就可以在數(shù)據(jù)庫服務(wù)器上用 postgres帳號通過psql或者pgAdmin等等客戶端操作數(shù)據(jù)庫了库说。
sudo -u postgres passwd
輸入新的 UNIX 密碼:
重新輸入新的 UNIX 密碼:
passwd:已成功更新密碼