usradd postgres
echo “postgres” --stdin |passwd postgres
yum groupinstall -y “Development Tools” “Legacy UNIX Compatibility”
yum install -y bison flex readline* zlib-devel gcc* gmake
mkdir -p /usr/local/pg12
mkdir -p /pgdata/12/data
chown -R postgres.postgres /pgdata/
chown -R postgres.postgres /usr/local/pg12
chmod 700 /pgdata/12/data -R
tar -xf postgresql-12.6.tar.gz
cd postgresql-12.6/
./configure --prefix=/usr/local/pg12 --with-pgport=1921 ##默认端口5432
gmake world
gmake install world
–PostgreSQL, contrib, and documentation successfully made. Ready to install.
su - postgres
vi .pg126
export PGDATA=/pgdata/12/data
export LANG=en_US.utf8
export PGHOME=/usr/local/pg12
export LD_LIBRARY_PATH=LD_LIBRARY_PATH
export DATE=‘date +"%Y%m%d%H%M"’
export PATH=PATH
export MANPATH=MANPATH
export PGUSER=postgres
export PGPORT=1921
----初始化数据
su - postgres
###简易初始化
initdb -D /pgdata/12/data -W
###生产建议初始化
initdb -A md5 -D /pgdata/12/data -E utf8 --locale=C -W
pg_ctl -D /pgdata/12/data -l logfile start
pg_ctl stop -mf
连接命令
psql -d postgres -h 10.10.10.40 -p 1921 -U postgres




