1)解压postgresql.tar.gz (tar -zxvf postgresql.tar.gz)
2)创建postgresql用户(useradd postgres;passwd postgres)
2)./configure --prefix=安装目录
3)make #编译
4)make install #安装
5)mkdir data #安装目录新建启动data目录
6)bin/initdb -D 新建data目录 #初始化指向data目录
7)对应修改data目录下pg_hba.conf和postgresql.conf (配置访问机器和端口等)
8)启动 :./pg_ctl -D 新建data目录地址 -l logfile start
关闭:./pg_ctl -D 新建data目录地址 stop
9)进入数据库修改密码:
./psql -U 用户名 -d postgres
10)alert usert postgres with password 'new password'
其他操作:
1.postgresql 启动
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/pgsql_data -l logfile start
2.postgresql 停止
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/pgsql_data stop
3.白名单配置pg_hba.conf
host all all 127.0.0.1/32 md5
host all all 192.168.199.1/24 md5
host all all 172.30.0.1/24 md5
host all all 0.0.0.0/0 md5
#注释: #---/32对应一台主机
#---/24对应一段网络
#---0.0.0.0/0对应所有
md5加密、 trust信任
4、防止暴力破解
验证失败后, 延迟一段时间的状态返回,才能继续验证(9版本的不能用)白名单限制
alter system set shared_preload_libraries=auth_delay;
alter system set auth_delay.milliseconds=10000;//10秒