1.源码包下载
wget :https://www.postgresql.org/ftp/source/v9.6.2/
2.创建安装及日志目录,创建日志文件用户群组及用户
mkdir -p /opt/postgre/data
mkdir -p /opt/postgre/log
touch log/psql.log
groupadd postgres
useradd postgres -g postgres
3.编译安装源码包
./configure --prefix=/opt/postgresql --enable-profiling --without-readline
make&&make install
4.初始化数据库
cd /opt/postgres/bin
su postgres
./initdb -D /opt/postgre/data/
初始化成功提示一下内容:Success. You can now start the database server
5.启动数据库
./pg_ctl -D /opt/postgresql/data -l logfile start
-D:-D 后面是数据库文件存放的目录,如果不指定则默认在/var/lib/下
6.添加为服务:
cd /opt/postgre/bin
./pg_ctl start -l logfile -D /opt/postgre/data
7.查看数据库是否启动:
ps -A | grep postgres
启动正常如下图:

8.命令行登录:
psql -U username -d dbname -h hostip -p port

9.停服命令
./pg_ctl stop -D /opt/postgre/data
10.进入bin目录,查看当前EDB数据库运行状态
./pg_ctl -D /opt/PostgresPlus/9.4AS/data status
1.36关闭数据库./pg_ctl -D /opt/PostgresPlus/9.4AS/data stop -m fast
11.修改配置文件
安 装PostgreSQL数据库之后,默认是只接受本地访问连接。如果想在其他主机上访问PostgreSQL数据库服务器,就需要进行相应的配置。
配置远 程连接PostgreSQL数据库的步骤很简单,只需要修改data目录下的pg_hba.conf和postgresql.conf。
pg_hba.conf:配置对数据库的访问权限,

postgresql.conf:配置PostgreSQL数据库服务器的相应的参数。修改listen_addresses参数设置访问IP限制

修改用户密码:
ALTER USER pgadmin WITH PASSWORD '123456'

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code