# 源码安装 tar zxvf postgresql-10.0.tar.gz mv postgresql-10.0 /usr/local/pgsql cd /usr/local/pgsql/ ./configure --prefix=/usr/local/pgsql --without-readline make make install # 添加用户,设置目录权限 adduser postgres passwd postgres mkdir -p /usr/local/pgsql/data chown -R postgres:root /usr/local/pgsql # 设置环境变量 > su - postgres > vim ~/.bash_profile export PATH=$PATH:/usr/local/pgsql/bin > source ~/.bash_profile # 允许所有连接 > vim /usr/local/pgsql/data/pg_hba.conf host all all 0.0.0.0/0 trust # 侦听所有连接 > vim /usr/local/pgsql/data/postgresql.conf listen_addresses = '*' logging_collector = on # 添加启动服务(确认文件postgresql内的目录正确) cp /usr/local/pgsql/contrib/start-scripts/linux /etc/init.d/postgresql chmod u+x /etc/init.d/postgresql # 添加开启自启动 chkconfig --add postgresql # 启动服务 service postgresql start # 切换用户,初始化数据并创建测试库(确认data目录下为空) su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data createdb test psql test
pgadmin4 安装:
#下载 pgadmin4 https://www.pgadmin.org/download/pgadmin-4-python-wheel/ # 安装 pgadmin4 > pip install pgadmin4-2.0-py2.py3-none-any.whl # 设置服务器地址 > vim /usr/lib/python2.7/site-packages/pgadmin4/config.py DEFAULT_SERVER = '192.168.40.10' # 设置邮箱用户&密码,启动服务 > python /usr/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py # 浏览器访问 http://192.168.40.10:5050/
官方安装参考:
https://www.postgresql.org/docs/10/static/installation.html(EN)
http://www.postgres.cn/docs/9.3/installation.html(CN)
pgadmin4 文档:https://www.pgadmin.org/docs/pgadmin4/dev/index.html
原文链接:https://www.f2er.com/postgresql/193435.html