标签:安装postgresql replication phppgadmin
[root@server ~]# yum -y install postgresql-server
[root@server ~]# postgresql-setup initdb
Initializing database ... OK
[root@server ~]# vim /var/lib/pgsql/data/postgresql.conf
# line 59: 取消备注并且修改以便远程主机访问
listen_addresses = ‘*‘
# line 395: 取消备注并且修改日志格式
log_line_prefix = ‘%t %u %d ‘
[root@server ~]# systemctl start postgresql
[root@server ~]# systemctl enable postgresql
# 设置密码
[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] 成功登陆系统,并可以在此配置数据库.
本文出自 “11830455” 博客,请务必保留此出处http://11840455.blog.51cto.com/11830455/1837503
Linux与云计算——第二阶段Linux服务器架设 第一十二章:数据库搭建—PostgreSQL
标签:安装postgresql replication phppgadmin
原文地址:http://11840455.blog.51cto.com/11830455/1837503