postgresql 安装配置全过程 (亲测)

前端之家收集整理的这篇文章主要介绍了postgresql 安装配置全过程 (亲测)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
源码路径:/home/admin15/postgis/postgresql/postgresql-8.3.4
1、安装
#./configure --prefix=/opt/postgresql --enable-profiling --without-readline
make
make install
(Postgresql installation complete.)
# groupadd postgres
# useradd -g postgres -d /opt/postgresql/user postgres
cd /opt/postgresql
mkdir data
mkdir log
touch log/psql.log
cd /opt/postgresql/user
vi .bash_profile
在最后添加
export PATH=$PATH:/opt/postgresql/bin
export MANPATH=$MANPATH:/opt/postgresql/man
export LD_LIBRARYPATH=$LD_LIBRARYPATH:/opt/postgresql/lib
保存退出
:wq
3、初始数据库
#su - postgres
$cd /opt/postgresql/bin/
$./initdb -D /opt/postgresql/data/
(Success. You can now start the database server)
#./pg_ctl -D /opt/postgresql/data -l logfile start
出现问题
_mcleanup: gmon.out: Permission denied
sh: logfile: Permission denied
修改权限
$exit
# cd /opt
#chown -R postgres.postgres postgresql/
#su - postgres
$cd /opt/postgresql/bin/
$./initdb -D /opt/postgresql/data/
(Success. You can now start the database server using:
./postgres -D /opt/postgresql/data
or
./pg_ctl -D /opt/postgresql/data -l logfile start)
初始数据库完成
./pg_ctl -D /opt/postgresql/data -l logfile start
启动
(server starting)
查看是否启动
#ps -A | grep postgres
(6368 pts/1 00:00:00 postgres
6370 ? 00:00:00 postgres
6371 ? 00:00:00 postgres
6372 ? 00:00:00 postgres
6373 ? 00:00:00 postgres)
4、测试
创建test数据库
$createdb test
查看当前所有数据库
$psql -l
(List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | UTF8
template0 | postgres | UTF8
template1 | postgres | UTF8
test | postgres | UTF8
(4 rows))
5、创建数据库超级用户
$createuser -sADEP pgadmin
(Enter password for new role:
Enter it again:
Shall the new role be allowed to create more new roles? (y/n) y)
中间输入两次新用户密码
创建成功
测试用户登录
$psql -d test -U pgadmin
(Welcome to psql 8.3.8 (server 8.3.4),the Postgresql interactive terminal.
Type: \copyright for distribution terms
\h for help with sql commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
test=> )
6、在windows上安装 pgadminIII,exe包,一路next,ok!
连接配置
修改/opt/postgresql/data/下的pg_hba.conf和postgresql.conf
$cd /opt/postgresql/data/
$vi postgresql.conf
去掉这两行前的#号
listen_addresses = 'localhost'
port = 5432
修改第一句为
listen_addresses = '*'
保存退出
$vi pg_hba.conf
最后添加
hostssl all all 192.168.100.0/24 md5
实现允许192.168.100.0/24网段的连接,使用SSL连接,通过md5来认证;
重新加载配置
$cd /opt/postgresql/bin/
$./pg_ctl -D /opt/postgresql/data reload

原文链接:https://www.f2er.com/postgresql/197120.html

猜你在找的Postgre SQL相关文章