免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
centos7 安裝postgresql

1、驗(yàn)證環(huán)境

  • 操作系統(tǒng) CentOS-7-x86_64-Everything-1511
  • postgresql版本 PostgreSQL 9.6.3:https://www.postgresql.org/download/linux/redhat/

2、安裝

  • 安裝rpm
    [root@psql_master ~]# yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
  • 安裝客戶端
    [root@psql_master ~]# yum install -y postgresql96
  • 安裝服務(wù)器端
    #yum安裝postgresql,默認(rèn)會(huì)建一個(gè)名為”postgres”的系統(tǒng)賬號(hào),用于執(zhí)行PostgreSQL;
    #同時(shí)數(shù)據(jù)庫(kù)中也會(huì)生成一個(gè)名為”postgres”的數(shù)據(jù)庫(kù)用戶,且密碼已自動(dòng)生成,需要進(jìn)入數(shù)據(jù)庫(kù)后修改;
    #PostgreSQL在數(shù)據(jù)庫(kù)用戶同名的系統(tǒng)賬號(hào)下登錄免密。
    [root@psql_master ~]# yum install -y postgresql96-server
  • 初始化
    [root@psql_master ~]# /usr/pgsql-9.6/bin/postgresql96-setup initdb
  • 設(shè)置開(kāi)機(jī)啟動(dòng)
    [root@psql_master ~]# systemctl enable postgresql-9.6
  • 啟動(dòng)
    [root@psql_master ~]# systemctl start postgresql-9.6

3、配置使用

  • 修改用戶密碼
    #yum安裝postgresql,默認(rèn)會(huì)建一個(gè)名為”postgres”的系統(tǒng)賬號(hào),用于執(zhí)行PostgreSQL;
    [root@psql_master ~]# su - postgres
    
    #切換用戶后,提示符變更為“-bash-4.2$”;
    #同時(shí)數(shù)據(jù)庫(kù)中也會(huì)生成一個(gè)名為”postgres”的數(shù)據(jù)庫(kù)用戶,且密碼已自動(dòng)生成;
    #PostgreSQL在數(shù)據(jù)庫(kù)用戶同名的系統(tǒng)賬號(hào)下登錄免密;
    -bash-4.2$ psql -U postgres
    
    #進(jìn)入數(shù)據(jù)庫(kù)后修改密碼;
    postgres=# alter user postgres with password 'postgres@123'
    

  • 允許遠(yuǎn)程訪問(wèn)
    #配置文件中,默認(rèn)只能本機(jī)訪問(wèn)postgresql;
    #修改listen_addresses = 'localhost'為listen_addresses = '*',允許所有遠(yuǎn)程訪問(wèn);
    #修改配置文件需要重啟服務(wù)。
    [root@psql_master ~]# sed -i "s|#listen_addresses = 'localhost'|listen_addresses = '*'|g" /var/lib/pgsql/9.6/data/postgresql.conf
  • 主機(jī)認(rèn)證
    #在第82行之后,”IPv4 local connections”下新增允許的客戶端;
    #“host” 代表主機(jī)類(lèi)型,第一個(gè)“all”代表db ,第二個(gè)“all”代表user ,“172.29.3.67/32” 代表client ip,“trust”代表認(rèn)證方式;
    #認(rèn)證方式除“trust”外,還有“peer”, “ident”, “md5”, “password”等,具體可參考pg-hba文件: https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html
    #修改pg.hba文件需要重啟服務(wù)。
    [root@psql_master ~]# vim /var/lib/pgsql/9.6/data/pg_hba.conf
    host    all             all             172.29.3.67/32          trust

  • 設(shè)置環(huán)境變量
    [root@psql_master ~]# vim /etc/profile
    export PATH=$PATH:/usr/pgsql-9.6/bin
    
    [root@psql_master ~]# source /etc/profile

  • 重啟服務(wù)
    [root@psql_master ~]# systemctl restart postgresql-9.6
  • 防火墻添加5432端口
    開(kāi)端口命令: firewall-cmd --zone=public --add-port=5432/tcp --permanent
    重啟防火墻:systemctl restart firewalld.service

4、測(cè)試

  • 查看端口
    [root@psql_master ~]# netstat -tunlp
  • 創(chuàng)建用戶
    postgres=# create user postuser1 with password 'user1@123';
  • 創(chuàng)建數(shù)據(jù)庫(kù)
    postgres=# create database postdb1 owner postuser1; 同時(shí)制定數(shù)據(jù)庫(kù)所有者
  • 數(shù)據(jù)庫(kù)賦權(quán)
    postgres=# grant all privileges on database postdb1 to postuser1
    #未賦權(quán)則賬戶只能登錄控制臺(tái)

  • 登錄新建數(shù)據(jù)庫(kù)
    #在操作系統(tǒng)層使用新建的賬號(hào)登錄新建的數(shù)據(jù)庫(kù),登錄后提示符為“postdb1=>”;
    #如果在postgres賬戶下直接使用“postgres=# \c postdb1;”登錄,則登錄用戶依然是postgres,
    -bash-4.2$ psql -U postuser1 -d postdb1 -h 127.0.0.1 -p 5432

  • 創(chuàng)建表
    postdb1=> create table tb1(
              id int primary key,
              name VARCHAR(20), 
              salary real
              );
  • 插入數(shù)據(jù)
    postdb1=> insert into tb1(
              id, name, salary)
              values(
              101, 'Mike', 5000.00
              );
  • 查詢
    postdb1=>select * from tb1;

5、pgadmin連接postgresql

  • pgadmin下載地址:https://www.pgadmin.org/download/
  • 添加服務(wù)器

    打開(kāi)pgadmin—>添加新的服務(wù)器—>(通常標(biāo)簽)名稱自定義—>connection標(biāo)簽)主機(jī)名稱與postgresql用戶密碼按需填寫(xiě),其余可采用默認(rèn)配置—>保存

    

 

 

  

 

 

  • 圖形化查看

 

        

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
PostgreSQL11.3 創(chuàng)建用戶和創(chuàng)建數(shù)據(jù)庫(kù)
Centos7安裝和配置Postgresql數(shù)據(jù)庫(kù)及Navicat連接
Oracle最佳替代者PostgreSQL數(shù)據(jù)庫(kù)的整體安全性
用Keepalived實(shí)現(xiàn)PostgreSQL高可用
PostgreSQL查看數(shù)據(jù)目錄總結(jié)
修改postgres的密碼
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服