注:postgresql
中角色
就是用戶
- 遠程登錄配置(以
postgresql95
為例)
- 配置
vi /var/lib/pgsql/9.5/data/pg_hba.conf
host all all 192.168.0.102/24 password
192.168.0.102
是允許遠程登錄的ip
- 配置
vi /var/lib/pgsql/9.5/data/postgresql.conf
listen_addresses='*'
- 重啟服務
systemctl restart postgresql-9.5.service
注:如果不能登錄,應該是沒有登錄權限
alter user root login;
- 用角色
engine
登錄數(shù)據(jù)庫engine
配置遠程登錄,用engine
登錄engine
數(shù)據(jù)庫
image.png
- 用
postgres-client
登錄數(shù)據(jù)庫
- 更改
centos7
的用戶postgres
密碼為postgres
,第二個步驟- 用角色
postgres
登錄postgresql
su root
su postgres
psql
- 更改數(shù)據(jù)庫中
postgres
用戶的密碼為postgres
ALTER USER postgres WITH PASSWORD 'postgres';
- 配置
vi /var/lib/pgsql/9.5/data/pg_hba.conf
local all all password
- 重啟數(shù)據(jù)庫服務
systemctl restart postgresql-9.5.service
登錄數(shù)據(jù)庫,輸入密碼
image.png- 切換數(shù)據(jù)庫
\c databaseName
- 切換角色
\c - userName
image.png