最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

CentOS 7下安裝PostgreSQL 9.6的教程分享

 更新時(shí)間:2017年02月07日 11:27:38   作者:標(biāo)點(diǎn)符  
PostgreSQL在我心目中的地位要遠(yuǎn)遠(yuǎn)高于MySQL,雖然流行對(duì)比MySQL低很對(duì),但是功能性一致走在MySQL的前面。下面這篇文章主要介紹了CentOS 7下安裝PostgreSQL數(shù)據(jù)庫(kù)的方法,需要的朋友可以參考借鑒,一起來(lái)看看吧。

前言

PostgreSQL是一個(gè)強(qiáng)大開(kāi)源的對(duì)象關(guān)系類型數(shù)據(jù)庫(kù)系統(tǒng),它能運(yùn)行于幾乎所有主要的操作系統(tǒng),包括Linux、Unix(AIX、BSD、HP-UX、SGI IRIX、Mac OS、Solaris、Tru64)、Windows OS。對(duì)于新的項(xiàng)目我是非常建議使用PostgreSQL。這里就簡(jiǎn)單的整理下CentOS下的安裝過(guò)程。

CentOS的源中自帶有PostgreSQL,可以通過(guò) yum list | grep postgresql 查看系統(tǒng)自帶的版本,我這邊看到的是9.2版本,個(gè)人還是比較建議安裝更新的版本。

安裝

1、安裝 yum 源(地址從 http://yum.postgresql.org/repopackages.php 獲?。?/p>

yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm

這里選擇的是最新的9.6版本,安裝完畢后使用 yum update 更新源信息,然后再使用 yum list | grep postgresql ,是否已經(jīng)有最新版本的postgresql。

[root@localhost ~]# yum list|grep postgresql
calligra-kexi-driver-postgresql.x86_64 2.9.10-1.el7     epel  
collectd-postgresql.x86_64    5.6.0-1.el7     epel  
freeradius-postgresql.x86_64   3.0.4-6.el7     base  
libreoffice-postgresql.x86_64   1:4.3.7.2-5.el7_2.1   updates 
mingw32-postgresql.noarch    9.3.4-2.el7     epel  
mingw64-postgresql.noarch    9.3.4-2.el7     epel  
opendbx-postgresql.x86_64    1.4.6-6.el7     epel  
opensips-postgresql.x86_64    1.10.5-3.el7     epel  
owncloud-postgresql.noarch    9.0.4-1.el7     epel  
pcp-pmda-postgresql.x86_64    3.10.6-2.el7     base  
pdns-backend-postgresql.x86_64   3.4.10-1.el7     epel  
perdition-postgresql.x86_64    2.1-5.el7      epel  
postgresql.i686       9.2.15-1.el7_2     updates 
postgresql.x86_64      9.2.15-1.el7_2     updates 
postgresql-contrib.x86_64    9.2.15-1.el7_2     updates 
postgresql-devel.i686     9.2.15-1.el7_2     updates 
postgresql-devel.x86_64     9.2.15-1.el7_2     updates 
postgresql-docs.x86_64     9.2.15-1.el7_2     updates 
postgresql-jdbc.noarch     9.4.1212-1.rhel7    pgdg96 
postgresql-jdbc-javadoc.noarch   9.4.1212-1.rhel7    pgdg96 
postgresql-libs.i686     9.2.15-1.el7_2     updates 
postgresql-libs.x86_64     9.2.15-1.el7_2     updates 
postgresql-odbc.x86_64     09.03.0100-2.el7    base  
postgresql-pgpool-II.x86_64    3.4.6-1.el7     epel  
postgresql-pgpool-II-devel.x86_64  3.4.6-1.el7     epel  
postgresql-pgpool-II-extensions.x86_64 3.4.6-1.el7     epel  
postgresql-plperl.x86_64    9.2.15-1.el7_2     updates 
postgresql-plpython.x86_64    9.2.15-1.el7_2     updates 
postgresql-plruby.x86_64    0.5.3-13.el7     epel  
postgresql-plruby-doc.x86_64   0.5.3-13.el7     epel  
postgresql-pltcl.x86_64     9.2.15-1.el7_2     updates 
postgresql-server.x86_64    9.2.15-1.el7_2     updates 
postgresql-test.x86_64     9.2.15-1.el7_2     updates 
postgresql-unit96.x86_64    1.0-1.rhel7     pgdg96 
postgresql-unit96-debuginfo.x86_64  1.0-1.rhel7     pgdg96 
postgresql-upgrade.x86_64    9.2.15-1.el7_2     updates 
postgresql96.x86_64      9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-contrib.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-debuginfo.x86_64   9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-devel.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-docs.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-libs.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-odbc.x86_64    09.05.0400-1PGDG.rhel7   pgdg96 
postgresql96-plperl.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-plpython.x86_64   9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-pltcl.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-python.x86_64    4.2-1PGDG.rhel7    pgdg96 
postgresql96-python-debuginfo.x86_64 4.2-1PGDG.rhel7    pgdg96 
postgresql96-server.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
postgresql96-tcl.x86_64     2.1.1-1.rhel7     pgdg96 
postgresql96-tcl-debuginfo.x86_64  2.1.1-1.rhel7     pgdg96 
postgresql96-test.x86_64    9.6.1-1PGDG.rhel7    pgdg96 
proftpd-postgresql.x86_64    1.3.5b-2.el7     epel  
python-testing.postgresql.noarch  1.1.0-2.el7     epel  
qt-postgresql.i686      1:4.8.5-12.el7_2    updates 
qt-postgresql.x86_64     1:4.8.5-12.el7_2    updates 
qt5-qtbase-postgresql.x86_64   5.6.1-3.el7     epel  
soci-postgresql.x86_64     3.2.3-1.el7     epel  
soci-postgresql-devel.x86_64   3.2.3-1.el7     epel

2、安裝PostgreSQL

這里最核心的是要安裝postgresql96-server和postgresql96-contrib,其中”contrib”包里包含了一些常用的組件和方法。

yum install postgresql96-server postgresql96-contrib

安裝后,可執(zhí)行文件在 /usr/pgsql-9.5/bin/, 數(shù)據(jù)和配置文件在 /var/lib/pgsql/9.6/data/

3、初始化數(shù)據(jù)庫(kù)

/usr/pgsql-9.6/bin/postgresql96-setup initdb

4、默認(rèn)情況下PostgreSQL不支持密碼登錄,如需支持需要修改配置文件

vi /var/lib/pgsql/9.6/data/pg_hba.conf

將未注釋行中的ident 替換為 md5

# TYPE DATABASE  USER   ADDRESS     METHOD
 
# "local" is for Unix domain socket connections only
local all    all          peer
# IPv4 local connections:
host all    all    127.0.0.1/32   ident
# IPv6 local connections:
host all    all    ::1/128     ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication  postgres        peer
#host replication  postgres  127.0.0.1/32   ident
#host replication  postgres  ::1/128     ident

如需開(kāi)啟遠(yuǎn)程訪問(wèn),可編輯/var/lib/pgsql/9.6/data/postgresql.conf 文件。

#listen_addresses = 'localhost'   修改為 listen_addresses='*' (當(dāng)然,此處‘*'也可以改為任何你想開(kāi)放的服務(wù)器IP)

另外對(duì)于特定的IP還可以設(shè)置開(kāi)啟信任遠(yuǎn)程連接,修改/var/lib/pgsql/9.6/data/pg_hba.conf,按下面的格式進(jìn)行添加設(shè)置。

# IPv4 local connections:
 host all   all  127.0.0.1/32  trust
 host all   all  8.8.8.8/32(需要連接的服務(wù)器IP) trust

修改完配置以后不要忘了重啟服務(wù)。

5、管理服務(wù),和其他服務(wù)一樣還是用systemd進(jìn)行管理

systemctl start postgresql-9.6 #啟動(dòng)服務(wù)
systemctl restart postgresql-9.6 #重啟服務(wù)
systemctl stop postgresql-9.6 #停止服務(wù)
systemctl enable postgresql-9.6 #自動(dòng)啟動(dòng)

6、登錄PostgreSQL

PostgreSQL 安裝完成后,會(huì)建立一下‘postgres'用戶,用于執(zhí)行PostgreSQL,數(shù)據(jù)庫(kù)中也會(huì)建立一個(gè)'postgres'用戶,如果我們要使用PostgreSQL就必須先登錄此帳號(hào)。

sudo -i -u postgres

執(zhí)行后提示符會(huì)變?yōu)?‘-bash-4.2$',再運(yùn)行

同構(gòu)執(zhí)行進(jìn)入 psql 進(jìn)入postgresql命令行環(huán)境。

[root@localhost ~]# sudo -i -u postgres
-bash-4.2$ psql
psql (9.6.1)
Type "help" for help.
 
postgres=#

接著可以執(zhí)行 ALTER USER postgres WITH PASSWORD '123456' 來(lái)設(shè)置postgres用戶密碼,可通過(guò) \q  退出數(shù)據(jù)庫(kù)。

7、打開(kāi)防火墻

CentOS 防火墻中內(nèi)置了PostgreSQL服務(wù),配置文件位置在/usr/lib/firewalld/services/postgresql.xml,只需以服務(wù)方式將PostgreSQL服務(wù)開(kāi)放即可。

firewall-cmd --add-service=postgresql --permanent 開(kāi)放postgresql服務(wù)
firewall-cmd --reload 重載防火墻

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流。

相關(guān)文章

  • PostgreSQL因大量并發(fā)插入導(dǎo)致的主鍵沖突的解決方案

    PostgreSQL因大量并發(fā)插入導(dǎo)致的主鍵沖突的解決方案

    在數(shù)據(jù)庫(kù)操作中,并發(fā)插入是一個(gè)常見(jiàn)的場(chǎng)景,然而,當(dāng)大量并發(fā)插入操作同時(shí)進(jìn)行時(shí),可能會(huì)遇到主鍵沖突的問(wèn)題,本文將深入探討 PostgreSQL 中解決因大量并發(fā)插入導(dǎo)致的主鍵沖突的方法,并通過(guò)具體的示例進(jìn)行詳細(xì)說(shuō)明,需要的朋友可以參考下
    2024-07-07
  • Postgresql自定義函數(shù)詳解

    Postgresql自定義函數(shù)詳解

    這篇文章主要介紹了Postgresql自定義函數(shù)詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-12-12
  • postgres array_to_string和array的用法講解

    postgres array_to_string和array的用法講解

    這篇文章主要介紹了postgres array_to_string和array的用法講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01
  • Linux CentOS 7源碼編譯安裝PostgreSQL9.5

    Linux CentOS 7源碼編譯安裝PostgreSQL9.5

    這篇文章主要為大家詳細(xì)介紹了Linux CentOS 7源碼編譯安裝PostgreSQL9.5的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • PostgreSQL數(shù)據(jù)庫(kù)中匿名塊的寫(xiě)法實(shí)例

    PostgreSQL數(shù)據(jù)庫(kù)中匿名塊的寫(xiě)法實(shí)例

    這篇文章主要介紹了PostgreSQL數(shù)據(jù)庫(kù)中匿名塊的寫(xiě)法實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01
  • postgresql兼容MySQL on update current_timestamp問(wèn)題

    postgresql兼容MySQL on update current_timestamp

    這篇文章主要介紹了postgresql兼容MySQL on update current_timestamp問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-03-03
  • PostgreSQL數(shù)據(jù)庫(kù)中DISTINCT關(guān)鍵字的四種用法詳解

    PostgreSQL數(shù)據(jù)庫(kù)中DISTINCT關(guān)鍵字的四種用法詳解

    PostgreSQL 不但高度兼容 SQL 標(biāo)準(zhǔn),同時(shí)還對(duì)很多語(yǔ)法進(jìn)行了擴(kuò)展,可以用于實(shí)現(xiàn)一些特殊的功能,今天我們就來(lái)介紹一下 PostgreSQL 數(shù)據(jù)庫(kù)中 DISTINCT 關(guān)鍵字的 4 種不同用法,需要的朋友可以參考下
    2024-04-04
  • Navicat設(shè)置PostgreSQL數(shù)據(jù)庫(kù)的表主鍵ID自增的方法

    Navicat設(shè)置PostgreSQL數(shù)據(jù)庫(kù)的表主鍵ID自增的方法

    這篇文章主要介紹了Navicat設(shè)置PostgreSQL數(shù)據(jù)庫(kù)的表主鍵ID自增的方法,文章通過(guò)圖文結(jié)合的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2024-06-06
  • 解決PostgreSQL服務(wù)啟動(dòng)后占用100% CPU卡死的問(wèn)題

    解決PostgreSQL服務(wù)啟動(dòng)后占用100% CPU卡死的問(wèn)題

    前文書(shū)說(shuō)到,今天耗費(fèi)了九牛二虎之力,終于馴服了NTFS權(quán)限安裝好了PostgreSQL,卻不曾想,服務(wù)啟動(dòng)后,新的狀況又出現(xiàn)了。
    2009-08-08
  • 基于PostgreSql 別名區(qū)分大小寫(xiě)的問(wèn)題

    基于PostgreSql 別名區(qū)分大小寫(xiě)的問(wèn)題

    這篇文章主要介紹了基于PostgreSql 別名區(qū)分大小寫(xiě)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-01-01

最新評(píng)論

常宁市| 剑川县| 丹寨县| 贵州省| 龙海市| 罗山县| 涪陵区| 平塘县| 壤塘县| 洛南县| 皮山县| 甘孜| 筠连县| 叙永县| 揭阳市| 界首市| 林州市| 灵石县| 鄯善县| 周宁县| 景泰县| 秀山| 娄底市| 连南| 鹿邑县| 米林县| 江达县| 门头沟区| 高台县| 双鸭山市| 库车县| 清水河县| 梁平县| 孟村| 玉屏| 莱阳市| 商城县| 西林县| 华坪县| 晋宁县| 锦屏县|