CentOS7 minimal postgresql 切換數(shù)據(jù)庫和角色 遠程登錄 登錄

注:postgresql角色就是用戶

  • 遠程登錄配置(以postgresql95為例)
  1. 配置
    vi /var/lib/pgsql/9.5/data/pg_hba.conf
host    all             all             192.168.0.102/24            password

192.168.0.102是允許遠程登錄的ip

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


    image.png
  3. 切換數(shù)據(jù)庫
    \c databaseName
  4. 切換角色
    \c - userName
    image.png
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。