日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Linux下安裝PostgreSQL并設(shè)置基本參數(shù)

在linux下安裝Postgresql有二進制格式安裝和源碼安裝兩種安裝方式,這里用的是二進制格式安裝。各個版本的Linux都內(nèi)置了Postgresql,所以可直接通過命令行安裝便可。本文用的是CentOS 6.5。

10年積累的網(wǎng)站設(shè)計、成都網(wǎng)站制作經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有羅莊免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

安裝Postgresql

# 安裝postgresql服務(wù)器

yum
install postgresql-
server
#依賴包是否安裝
Y/
N  Y

#第三方貢獻包

yum
install postgresql-
contrib
#依賴包是否安裝
Y/N  Y

安裝成功后,數(shù)據(jù)庫狀態(tài)

[root@localhost Hadoop]# service postgresql status
postmaster is stopped

嘗試啟動數(shù)據(jù)庫,但報錯,需要先初始化數(shù)據(jù)目錄

[root@localhost hadoop]# service postgresql start
/var/lib/pgsql/data is missing.Use "service postgresql initdb" to initialize the cluster first.
[root@localhost hadoop]# service postgresql initdb
Initializing database:                                                [OK]

啟動數(shù)據(jù)庫

通過service命令啟動Postgresql,需要注意的是,默認在安裝時會創(chuàng)建postgres用戶并安裝到此用戶下。而Postgresql 的默認數(shù)據(jù)庫也是用此用戶命名的。

[root@localhost hadoop]# service postgresql start
Starting postgresql service:                              [  OK  ]
[root@localhost hadoop]#
su -
postgres
-bash-
4.1
$ psql
psql (
8.4.
20
)
Type
"
help
"
for
help.

postgres=
# \l
                                  List of databases
  Name   |  Owner  | Encoding |  Collation  |    Ctype    |
  Access privileges 
-----------+----------+----------+-------------+-------------+-----------------------

postgres | postgres | UTF8    | en_US.UTF-
8 | en_US.UTF-
8 |

template0| postgres | UTF8    | en_US.UTF-
8 | en_US.UTF-
8 | =c/
postgres
                                                            : postgres=CTc/
postgres
template1| postgres | UTF8    | en_US.UTF-
8 | en_US.UTF-
8 | =c/
postgres
                                                            : postgres=CTc/
postgres
(
3
rows)

postgres=#

Postgresql 的Psql 就等于Oracle的Sqlplus一樣 ,直接用命令Psql登錄等于用操作系統(tǒng)驗證登錄,不需要輸入用戶名和密碼。

基本參數(shù)設(shè)置

在Centos下,默認的數(shù)據(jù)目錄在 /var/lib/pgsql/data 下 ,配置的參數(shù)文件就在此目錄下。

-bash-
4.1$
ls -
l
total
80

drwx------
5 postgres postgres 
4096 Nov
16
07:
43
base
drwx------
2 postgres postgres 
4096 Nov
17
23:
51
global
drwx------
2 postgres postgres 
4096 Nov
16
07:
43
pg_clog
-rw-------
1 postgres postgres 
3533 Nov
17
22:
05
pg_hba.conf
-rw-------
1 postgres postgres 
1631 Nov
16
07:
43
pg_ident.conf
drwx------
2 postgres postgres 
4096 Nov
18
00:
00
pg_log
drwx------
4 postgres postgres 
4096 Nov
16
07:
43
pg_multixact
drwx------
2 postgres postgres 
4096 Nov
18
00:
00
pg_stat_tmp
drwx------
2 postgres postgres 
4096 Nov
16
07:
43
pg_subtrans
drwx------
2 postgres postgres 
4096 Nov
16
07:
43
pg_tblspc
drwx------
2 postgres postgres 
4096 Nov
16
07:
43
pg_twophase
-rw-------
1 postgres postgres   
4 Nov
16
07:
43
PG_VERSION
drwx------
3 postgres postgres 
4096 Nov
16
07:
43
pg_xlog
-rw-------
1 postgres postgres
16877 Nov
17
21:
54
postgresql.conf
-rw-------
1 postgres postgres   
57 Nov
17
23:
51
postmaster.opts
-rw-------
1 postgres postgres   
45 Nov
17
23:
51 postmaster.pid

配置遠程登錄數(shù)據(jù)庫

1. 修改 postgresql.conf 文件,配置PostgreSQL數(shù)據(jù)庫服務(wù)器的相應(yīng)的參數(shù)

listen_addresses = '*'       # PostgreSQL安裝完成后,默認是只接受來在本機localhost的連接請求,此處將數(shù)據(jù)庫服務(wù)器的監(jiān)聽模式修改為監(jiān)聽所有主機發(fā)出的連接請求
port = 5432      #  默認端口,修改后要重啟數(shù)據(jù)庫

2. 修改 pg_hba.conf 文件,配置對數(shù)據(jù)庫的訪問權(quán)限

在最后一行加上配置,表示允許網(wǎng)段192.168.191.0上的所有主機使用所有合法的數(shù)據(jù)??用戶名訪問數(shù)據(jù)庫,

24是子網(wǎng)掩碼,表示允許IP范圍在 192.168.191.0--192.168.191.255 的計算機訪問。

3. 測試遠程登錄

首先修改默認數(shù)據(jù)庫用戶登錄密碼

-bash-4.1$ psql
psql (8.4.20)
Type "help" for help.

postgres=# \password

按提示修改密碼。

然后再從另一臺局域網(wǎng)機器上登錄

psql -U postgres -d postgres -h 192.168.191.5 -p 5432      -- 成功

其中 –u 指定用戶,-d 指定數(shù)據(jù)庫名 ,-h 指定host,-p 端口號,按提示輸入密碼。

 

另外,可視化客戶端推薦用DBeaver。

-- 感謝您付出的閱讀時間。


當前標題:Linux下安裝PostgreSQL并設(shè)置基本參數(shù)
本文來源:http://www.5511xx.com/article/cdgpgco.html