postgis启动_PostgreSQL的安装和启动方法大全
官方文檔
二進制安裝和啟動:
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
出處:http://blog.itpub.net/30126024/viewspace-2648733/
總結
以上是生活随笔為你收集整理的postgis启动_PostgreSQL的安装和启动方法大全的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果WWDC定档6月5日 有望发布首款混
- 下一篇: css3轮播不用jpuery_15款效果