pgsql9.6二进制安装

新增postgres用户和用户组:
groupadd postgres
useradd -g postgres postgres
echo "postgres" |passwd --stdin postgres
 
 
软件下载地址:
https://www.enterprisedb.com/download-postgresql-binaries
 
tar -zxvf postgresql-9.6.12-1-linux-x64-binaries.tar.gz 
mv pgsql /opt
 
创建数据文件目录
mkdir /data/pgsql_data/
chown postgres:postgres /data/pgsql_data/
chown postgres:postgres /opt/pgsql -R
 
echo "export PATH=$PATH:/opt/pgsql/bin">>/etc/profile 
source /etc/profile
 
切换用户 postgres,并执行初始化操作
/opt/pgsql/bin/initdb -E utf8 -D /data/pgsql_data/
 
启动数据库
/opt/pgsql/bin/postmaster -D /data/pgsql_data/ > /data/pgsql_data/pg_server.log 2>&1 &
 
登陆数据库
psql
 
添加新用户和创建数据库
create user admin with password 'chengce243';
create database mydb with encoding='utf8' owner=admin;
 
 
验证登录
psql -U admin -d mydb
 
停止postgresql的命令为: 
/opt/pgsql/bin/pg_ctl -D /data/pgsql_data/ stop 
 
 
 
原文地址:https://www.cnblogs.com/liang545621/p/12605715.html