婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > CentOS 7下安裝PostgreSQL 9.6的教程分享

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

熱門標簽:長沙電銷外呼防封卡是什么 智能外呼系統官網 小裙科技電銷機器人怎樣 青白江400企業電話申請 呼和浩特外呼系統原理是什么 外呼線路資源屬于電信業務嗎 河南電話外呼系統招商 crm外呼系統聯系方式 內蒙古營銷智能外呼系統哪個好

前言

PostgreSQL是一個強大開源的對象關系類型數據庫系統,它能運行于幾乎所有主要的操作系統,包括Linux、Unix(AIX、BSD、HP-UX、SGI IRIX、Mac OS、Solaris、Tru64)、Windows OS。對于新的項目我是非常建議使用PostgreSQL。這里就簡單的整理下CentOS下的安裝過程。

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

安裝

1、安裝 yum 源(地址從 http://yum.postgresql.org/repopackages.php 獲取)

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 ,是否已經有最新版本的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

安裝后,可執行文件在 /usr/pgsql-9.5/bin/, 數據和配置文件在 /var/lib/pgsql/9.6/data/

3、初始化數據庫

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

4、默認情況下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

如需開啟遠程訪問,可編輯/var/lib/pgsql/9.6/data/postgresql.conf 文件。

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

另外對于特定的IP還可以設置開啟信任遠程連接,修改/var/lib/pgsql/9.6/data/pg_hba.conf,按下面的格式進行添加設置。

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

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

5、管理服務,和其他服務一樣還是用systemd進行管理

systemctl start postgresql-9.6 #啟動服務
systemctl restart postgresql-9.6 #重啟服務
systemctl stop postgresql-9.6 #停止服務
systemctl enable postgresql-9.6 #自動啟動

6、登錄PostgreSQL

PostgreSQL 安裝完成后,會建立一下‘postgres'用戶,用于執行PostgreSQL,數據庫中也會建立一個'postgres'用戶,如果我們要使用PostgreSQL就必須先登錄此帳號。

sudo -i -u postgres

執行后提示符會變為 ‘-bash-4.2$',再運行

同構執行進入 psql 進入postgresql命令行環境。

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

接著可以執行 ALTER USER postgres WITH PASSWORD '123456' 來設置postgres用戶密碼,可通過 \q  退出數據庫。

7、打開防火墻

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

firewall-cmd --add-service=postgresql --permanent 開放postgresql服務
firewall-cmd --reload 重載防火墻

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。

您可能感興趣的文章:
  • Visual Studio(VS2017)配置C/C++ PostgreSQL9.6.3開發環境
  • Windows上PostgreSQL安裝配置教程
  • windows PostgreSQL 9.1 安裝詳細步驟
  • Visual Studio Code(VS Code)查詢PostgreSQL拓展安裝教程圖解

標簽:菏澤 池州 白山 楚雄 舟山 黃石 呼倫貝爾 安順

巨人網絡通訊聲明:本文標題《CentOS 7下安裝PostgreSQL 9.6的教程分享》,本文關鍵詞  CentOS,7下,安裝,PostgreSQL,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《CentOS 7下安裝PostgreSQL 9.6的教程分享》相關的同類信息!
  • 本頁收集關于CentOS 7下安裝PostgreSQL 9.6的教程分享的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 庆阳市| 澜沧| 平塘县| 贡觉县| 衡阳市| 姚安县| 安溪县| 永善县| 板桥市| 和硕县| 基隆市| 中卫市| 古浪县| 台东县| 云浮市| 三原县| 乌拉特中旗| 顺平县| 乾安县| 舟曲县| 深泽县| 玉门市| 潜山县| 滦南县| 绥棱县| 安顺市| 济源市| 蒙山县| 中阳县| 双辽市| 图木舒克市| 濮阳市| 佛山市| 万盛区| 隆林| 乐业县| 洪江市| 南华县| 永德县| 公安县| 郓城县|