Saminnet-Search Article Wiki Forum Piwigo SNS Cloud vtiger Sugar
PostgreSQL 銈ゃ兂銈广儓銉笺儷

PostgreSQL 銈ゃ兂銈广儓銉笺儷

PostgreSQL 銈掋偆銉炽偣銉堛兗銉仐銆併儑銉笺偪銉欍兗銈广偟銉笺儛銉笺倰妲嬬瘔銇椼伨銇欍

[1]銆PostgreSQL 銈掋偆銉炽偣銉堛兗銉仐銇﹁捣鍕曘仐銇俱仚銆偮

[www ~]#聽
yum聽-y install postgresql-server
[www ~]#聽
/etc/rc.d/init.d/postgresql initdb聽

Initializing database: 聽 聽 [ OK ]
[www ~]#聽
vi聽/var/lib/pgsql/data/postgresql.conf
# 59琛岀洰锛氥偝銉°兂銉堣В闄ゃ仐銇﹀鏇 ( 浠栥儧銈广儓銇嬨倝銇偄銈偦銈广倐鍙椼亼浠樸亼銈 )

listen_addresses = '
*
'
# 334琛岀洰锛氥偝銉°兂銉堣В闄ゃ仐銇﹀鏇 ( 銉偘銇舰寮忋倰 [鏃ユ檪 銉︺兗銈躲兗 DB 锝瀅銇ㄣ仚銈 )

log_line_prefix = '
%t %u %d
聽'
[www ~]#聽
/etc/rc.d/init.d/postgresql start聽

Starting postgresql service: 聽 聽 [ OK ]
[www ~]#聽
chkconfig聽postgresql on

[2] 绠$悊銉︺兗銈躲兗銇儜銈广儻銉笺儔瑷畾銆併亰銈堛伋銉︺兗銈躲兗鐧婚尣銈掋仐銇俱仚銆
# postgres 銉︺兗銈躲兗銇偣銈ゃ儍銉併仐銇︺儜銈广儻銉笺儔瑷畾

[www ~]#聽
su聽- postgres聽

-bash-4.1$聽
psql -c "alter user postgres with password 'password'"聽

ALTER ROLE
# DB銉︺兗銈躲兗銆宑ent銆嶃倰鏂拌鐧婚尣

-bash-4.1$聽
createuser cent聽

Shall the new role be a superuser? (y/n)聽
y
聽聽 聽聽
# DB銇鐞嗚呮ī闄愩倰涓庛亪銈嬪牬鍚堛伅銆寉銆

http://www.server-world.info/img/bgcom.gif);">

[3] cent 銉︺兗銈躲兗銇с儹銈般偆銉炽仐銆丏B鎿嶄綔銇儐銈广儓銈掋仐銇俱仚銆
# 銉嗐偣銉圖B浣滄垚

[www ~]$聽
createdb testdb聽

[www ~]$聽
psql -l聽
聽 聽聽
# 纰鸿獚

                                  List of databases
   Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileg
es
-----------+----------+----------+-------------+-------------+------------------
-----
 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
 testdb    | cent     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

# 銉嗐偣銉圖B銇帴缍

[www ~]$聽
psql testdb聽

psql (8.4.20)
Type "help" for help.
# 銉戙偣銉兗銉夎ō瀹

testdb=#聽
alter user cent with password 'password';聽

ALTER ROLE
# 銉嗐偣銉堛儐銉笺儢銉綔鎴

testdb=#聽
create table test ( no int,name text );聽

CREATE TABLE
# 銉嗐偣銉堛儑銉笺偪鎸垮叆

testdb=#聽
insert into test (no,name) values (1,'cent');聽

INSERT 0 1
# 纰鸿獚

testdb=#聽
select * from test;
 no | name
----+-------
  1 | cent
(1 row)
# 銉嗐偣銉堛儐銉笺儢銉墛闄

testdb=#聽
drop table test;聽

DROP TABLE
# 绲備簡

testdb=#聽
\q
# 銉嗐偣銉圖B鍓婇櫎

[www ~]$聽
dropdb testdb

phpPgAdmin 銈掋偆銉炽偣銉堛兗銉仐銇俱仚銆
#聽EPEL銇嬨倝銈ゃ兂銈广儓銉笺儷

[www ~]#聽
yum聽--enablerepo=epel -y install phpPgAdmin php-pgsql
[www ~]#聽
vi聽/etc/phpPgAdmin/config.inc.php
# 18琛岀洰锛氳拷瑷

$conf['servers'][0]['host'] = '
localhost
';
# 94琛岀洰锛氬鏇

$conf['owned_only'] =聽
true
;
[www ~]#聽
vi聽/var/lib/pgsql/data/pg_hba.conf
# 72琛岀洰锛氫笅瑷樸伄銈堛亞銇鏇 & 銈€偗銈汇偣瑷卞彲绡勫洸杩借

host    all         all         127.0.0.1/32          md5
host    all         all         10.0.0.0/24           md5
host    all         all         ::1/128               md5

[www ~]#聽
vi聽/etc/httpd/conf.d/phpPgAdmin.conf
# 11琛岀洰锛氥偄銈偦銈硅ū鍙疘P杩借

Allow from 127.0.0.1聽
10.0.0.0/24
[www ~]#聽
/etc/rc.d/init.d/httpd restart聽

Stopping httpd: [ OK ]
Starting httpd: [ OK ]

銆宧ttp://(銉涖偣銉堝悕)/phpPgAdmin銆嶃伀銈€偗銈汇偣銇椼仸銆佸乏銉°儖銉ャ兗銇孭ostgreSQL銆嶃倰銈儶銉冦偗銇椼伨銇欍

PostgreSQL 銇櫥閷层仐銇熴儲銉笺偠銉煎悕銇ㄣ儜銈广儻銉笺儔銇ц獚瑷笺仐銇俱仚銆

銉偘銈ゃ兂銇с亶銇俱仐銇熴傘亾銇鐞嗙敾闈€亱銈夈儑銉笺偪銉欍兗銈广倰鎿嶄綔銇欍倠銇撱仺銇屻仹銇嶃伨銇欍

Comments   

 
0 #1 Guest 2015-12-21 01:50
Other info from wiki postgreSQL
Quote
 

Articles by Date

Category Database

TweetTweet Share on LinkedInShare on LinkedIn Share on Google+Google+ Submit to RedditReddit Publish on WordPress WordPress Send emailSend email