linux上安裝postgresql9.5

1.查看源版本

czy@Mint ~ $ sudo apt-get update
czy@Mint ~ $ apt-cache madison postgresql
postgresql | 9.5+173ubuntu0.3 | http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
postgresql | 9.5+173ubuntu0.3 | http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
postgresql | 9.5+173ubuntu0.3 | http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
postgresql | 9.5+173ubuntu0.3 | http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
postgresql |    9.5+173 | http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
postgresql |    9.5+173 | http://archive.ubuntu.com/ubuntu xenial/main i386 Packages

可以看到默認只有9.5版本的

 

2.安裝

czy@Mint ~ $ sudo apt-get install postgresql
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關係樹       
正在讀取狀態信息... 完成       
將會同時安裝下列軟件:
  libpq5 postgresql-9.5 postgresql-client-9.5 postgresql-client-common
  postgresql-common
建議安裝:
  postgresql-doc locales-all postgresql-doc-9.5
推薦安裝:
  postgresql-contrib-9.5 sysstat
下列【新】軟件包將被安裝:
  libpq5 postgresql postgresql-9.5 postgresql-client-9.5
  postgresql-client-common postgresql-common
升級了 0 個軟件包,新安裝了 6 個軟件包,要卸載 0 個軟件包,有 612 個軟件包未被升級。
需要下載 4,162 kB 的歸檔。
解壓縮後會消耗 16.6 MB 的額外空間。
您希望繼續執行嗎? [Y/n] y
獲取:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpq5 amd64 9.5.21-0ubuntu0.16.04.1 [78.5 kB]
獲取:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-common all 173ubuntu0.3 [28.4 kB]
獲取:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-9.5 amd64 9.5.21-0ubuntu0.16.04.1 [876 kB]
獲取:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-common all 173ubuntu0.3 [154 kB]
獲取:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-9.5 amd64 9.5.21-0ubuntu0.16.04.1 [3,020 kB]
獲取:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql all 9.5+173ubuntu0.3 [5,392 B]
已下載 4,162 kB,耗時 5秒 (735 kB/s)   
正在預設定軟件包 ...
正在選中未選擇的軟件包 libpq5:amd64。
(正在讀取數據庫 ... 系統當前共安裝有 207658 個文件和目錄。)
正準備解包 .../libpq5_9.5.21-0ubuntu0.16.04.1_amd64.deb  ...
正在解包 libpq5:amd64 (9.5.21-0ubuntu0.16.04.1) ...
正在選中未選擇的軟件包 postgresql-client-common。
正準備解包 .../postgresql-client-common_173ubuntu0.3_all.deb  ...
正在解包 postgresql-client-common (173ubuntu0.3) ...
正在選中未選擇的軟件包 postgresql-client-9.5。
正準備解包 .../postgresql-client-9.5_9.5.21-0ubuntu0.16.04.1_amd64.deb  ...
正在解包 postgresql-client-9.5 (9.5.21-0ubuntu0.16.04.1) ...
正在選中未選擇的軟件包 postgresql-common。
正準備解包 .../postgresql-common_173ubuntu0.3_all.deb  ...
正在添加 postgresql-common 導致 /usr/bin/pg_config 轉移到 /usr/bin/pg_config.libpq-dev
正在解包 postgresql-common (173ubuntu0.3) ...
正在選中未選擇的軟件包 postgresql-9.5。
正準備解包 .../postgresql-9.5_9.5.21-0ubuntu0.16.04.1_amd64.deb  ...
正在解包 postgresql-9.5 (9.5.21-0ubuntu0.16.04.1) ...
正在選中未選擇的軟件包 postgresql。
正準備解包 .../postgresql_9.5+173ubuntu0.3_all.deb  ...
正在解包 postgresql (9.5+173ubuntu0.3) ...
正在處理用於 libc-bin (2.23-0ubuntu7) 的觸發器 ...
正在處理用於 man-db (2.7.5-1) 的觸發器 ...
正在處理用於 systemd (229-4ubuntu17) 的觸發器 ...
正在處理用於 ureadahead (0.100.0-19) 的觸發器 ...
ureadahead will be reprofiled on next reboot
正在設置 libpq5:amd64 (9.5.21-0ubuntu0.16.04.1) ...
正在設置 postgresql-client-common (173ubuntu0.3) ...
正在設置 postgresql-client-9.5 (9.5.21-0ubuntu0.16.04.1) ...
update-alternatives: 使用 /usr/share/postgresql/9.5/man/man1/psql.1.gz 來在自動模式中提供 /usr/share/man/man1/psql.1.gz (psql.1.gz)
正在設置 postgresql-common (173ubuntu0.3) ...
supported-versions: WARNING! Unknown distribution: linuxmint
ubuntu found in ID_LIKE, treating as Ubuntu
supported-versions: WARNING: Unknown Ubuntu release: 18.2
正在將用戶“postgres”加入到“ssl-cert”組中

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_au
  en_us
Removing obsolete dictionary files:
正在設置 postgresql-9.5 (9.5.21-0ubuntu0.16.04.1) ...
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale zh_CN.UTF-8
  socket /var/run/postgresql
  port   5432
update-alternatives: 使用 /usr/share/postgresql/9.5/man/man1/postmaster.1.gz 來在自動模式中提供 /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz)
正在設置 postgresql (9.5+173ubuntu0.3) ...
正在處理用於 libc-bin (2.23-0ubuntu7) 的觸發器 ...
正在處理用於 systemd (229-4ubuntu17) 的觸發器 ...
正在處理用於 ureadahead (0.100.0-19) 的觸發器 ...

 

3.進入命令行

安裝postgresql默認會創建用戶postgres,需要使用此用戶登錄客戶端

czy@Mint ~ $ sudo -i -u postgres
postgres@Mint ~ $ psql
psql (9.5.21)
Type "help" for help.

postgres=# \l

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章