[root@server ~]# yum -y install postgresql-serverphp
[root@server ~]# postgresql-setup initdb sql
Initializing database ... OK數據庫
[root@server ~]# vim /var/lib/pgsql/data/postgresql.confvim
# line 59: 取消備註而且修改以便遠程主機訪問bash
listen_addresses = '*'服務器
# line 395: 取消備註而且修改日誌格式ide
log_line_prefix = '%t %u %d 'post
[root@server ~]# systemctl start postgresql 測試
[root@server ~]# systemctl enable postgresqlui
# 設置密碼
[root@server ~]# su - postgres
-bash-4.2$ psql -c "alter user postgres with password 'redhat'"
ALTER ROLE
# 添加DB用戶 "jeffrey"
-bash-4.2$ createuser jeffrey
# 添加測試數據庫
-bash-4.2$ createdb testdb -O jeffrey
# 查看數據庫
[jeffrey@server ~]$ psql -l
List of databases
Name | Owner | Encoding | Collate | 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
testdb | jeffrey | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
# 鏈接到測試DB
[jeffrey@server ~]$ psql testdb
psql (9.2.13)
Type "help" for help.
# 配置密碼
testdb=> alter user jeffrey with password 'redhat';
ALTER ROLE
# 建立測試表
testdb=>create table test ( no int,name text );
CREATE TABLE
# 插入測試數據
testdb=>insert into test (no,name) values (1,'jeffrey');
INSERT 0 1
# 查看錶
testdb=> select * from test;
no | name
----+-------
1 | jeffrey
(1 row)
# 刪除測試數據庫
testdb=>drop table test;
DROP TABLE
# 退出
testdb=>\q
# 刪除測試DB
[jeffrey@server ~]$ dropdb testdb
[root@server ~]# yum -y install php php-mbstring php-pear
[root@server ~]# yum -y install phpPgAdmin php-pgsql
[root@server ~]# vi /etc/phpPgAdmin/config.inc.php
# line 18: 增長
$conf['servers'][0]['host'] = 'localhost';
# line 93: 若是你容許相似於root或postgres這些特權用戶登錄的話,修改成false
$conf['extra_login_security'] = false;
# line 99: 修改
$conf['owned_only'] = true;
[root@server ~]# vi /var/lib/pgsql/data/pg_hba.conf
# line 82: 參考下面內容修改而且添加訪問許可
host all all 127.0.0.1/32 md5
host all all 192.168.96.0/24 md5
host all all ::1/128 md5
[root@server ~]# vim /etc/httpd/conf.d/phpPgAdmin.conf
# line 11:添加訪問許可
Require local
Require ip 192.168.96.0/24
[root@server ~]# systemctl restart postgresql httpd
[5] 輸入認證的用戶名和密碼PostgreSQL.
[6] 成功登錄系統,並能夠在此配置數據庫.