欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

PostgreSQL的安裝和啟動方法

這篇文章主要介紹“PostgreSQL的安裝和啟動方法”,在日常操作中,相信很多人在PostgreSQL的安裝和啟動方法問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”PostgreSQL的安裝和啟動方法”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

創(chuàng)新互聯(lián)長期為成百上千家客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為雨花企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站制作,雨花網(wǎng)站改版等技術服務。擁有十多年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

官方文檔

二進制安裝和啟動:

https://www.postgresql.org/download/linux/redhat/

源碼安裝和啟動:

https://www.postgresql.org/docs/11/install-procedure.html

https://www.postgresql.org/docs/11/creating-cluster.html

https://www.postgresql.org/docs/11/server-start.html

https://www.postgresql.org/docs/current/kernel-resources.html

兩種方法

1、二進制安裝(linux是rpm包,windows是exe安裝文件)

2、源碼安裝,推薦安裝方式

二進制安裝

示例:centos7_64平臺,數(shù)據(jù)庫postgresql11,使用yum安裝

不使用yum的話可以直接使用rpm包安裝,rpm包下載地址https://yum.postgresql.org/rpmchart.php

1、安裝RPM的yum源,其實就是下載一個postgresql的yum源pgdg-redhat-all.repo文件到/etc/yum.repos.d目錄下,有了這個yum源后,就可以直接yum install postgresql11安裝postgresql數(shù)據(jù)庫了

yum install

https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2、安裝客戶端,先執(zhí)行search看有哪些PostgreSQL client可供安裝

yum search 'PostgreSQL client'

yum install postgresql11

3、安裝服務端,先執(zhí)行search看有哪些PostgreSQL server可供安裝,以下步驟安裝好后,會自動創(chuàng)建用戶postgres,自動創(chuàng)建目錄/usr/pgsql-11

yum search 'PostgreSQL server'

yum install postgresql11-server

4、初始化數(shù)據(jù)庫并啟用開機自動啟動

/usr/pgsql-11/bin/postgresql-11-setup initdb

systemctl enable postgresql-11

systemctl start postgresql-11

5、查看postgresql的進程

[root@zabbixtest2 ~]# ps -ef|grep postgres

postgres  1527     1  0 01:13 ?        00:00:00 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/

6、連接postgresql數(shù)據(jù)庫

su - postgres

psql -l

psql -d postgres

源碼安裝

1、建立postgresql用戶、內核資源的配置,主要涉及/etc/security/limits.conf、/etc/sysctl.conf文件,類似oracle也需要配置這兩個文件

2、解壓tar包,進入解壓目錄,使用root用戶執(zhí)行如下,最后的make install命令把軟件安裝到/postgresql/pgsql目錄

./configure --prefix=/postgresql/pgsql

make

make install

3、把軟件安裝目錄/postgresql/pgsql授權宿主用戶為postgresql

4、編輯postgresql用戶的.bash_profile文件,PATH= /postgresql/pgsql/bin :$PATH、LD_LIBRARY_PATH= /postgresql/pgsql /lib

5、初始化數(shù)據(jù)庫,后面兩條命令任意一條都可以

su - postgresql

initdb -D /postgresql/pgsql/data

pg_ctl -D /postgresql/pgsq l/data initdb

6、啟動postgresql程序,下面任意一個都可以,官方文檔建議使用pg_ctl

postgres -D /postgresql/pgsql/data >logfile 2>&1 &

pg_ctl start -D /postgresql/pgsql/data -l logfile

7、查看postgresql的進程

[root@zabbixtest1 ~]# ps -ef|grep postgres

postgre+   803     1  0 07:10 pts/0    00:00:00 /postgresql/pgsql/bin/postgres -D /postgresql/pgsql/data

8、連接postgresql數(shù)據(jù)庫,指定連接postgres庫

psql -l

psql -d postgres

備注 :psql命令不加端口和不加數(shù)據(jù)庫名,表示默認進入端口為5432并且數(shù)據(jù)庫名和初始數(shù)據(jù)庫initdb時的用戶名一樣的數(shù)據(jù)庫,比如初始數(shù)據(jù)庫initdb時的用戶名為A,則默認進入A庫。postgresql的默認端口是5432,默認數(shù)據(jù)庫是postgres、template0、template1

如果此時端口不是5432,則會報錯psql: FATAL:  role "A" does not exist

因為安裝用戶"A"對應的實例端口為其他,端口5432數(shù)據(jù)庫的Owner不是"A"

如果此時沒有"A"庫,則會報錯psql: FATAL:  database "A" does not exist

因為安裝用戶"A",默認進入"A"庫,而"A"庫是不存在的

9、創(chuàng)建一個名為test的數(shù)據(jù)庫

createdb test

10、查看數(shù)據(jù)庫狀態(tài)

pg_ctl status -D /postgresql/pgsql/data

11、關閉數(shù)據(jù)庫

pg_ctl stop -D /postgresql/pgsql/data

官方文檔Short Version簡要步驟

./configure

make

su

make install

adduser postgres

mkdir /usr/local/pgsql/data

chown postgres /usr/local/pgsql/data

su - postgres

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &

/usr/local/pgsql/bin/createdb test

/usr/local/pgsql/bin/psql test

到此,關于“PostgreSQL的安裝和啟動方法”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

本文標題:PostgreSQL的安裝和啟動方法
文章地址:http://chinadenli.net/article2/jpchoc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信小程序企業(yè)建站品牌網(wǎng)站制作外貿建站面包屑導航定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設