ubuntu16.04 安装制定版本的postgreSQL

1.添加源

# sudo vim /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
#:wq

2.导入安装密钥

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

3.安装

sudo apt-get install postgresql-9.6
或
sudo apt-get install postgresql

4. 远程访问配置

# sudo vim /etc/postgresql/10/main/postgresql.conf
listen_addresses = 'localhost'注释去掉并改为  listen_addresses = '*'
# sudo vim /etc/postgresql/10/main/pg_hba.conf
将
host    all             all             127.0.0.1/32            md5
修改为
host    all             all             0.0.0.0/0               md5
sudo su - postgres
psql
ALTER USER postgres PASSWORD '123456';
/etc/init.d/postgresql restart

5. 验证登录

psql -U postgres -h 你的ip
# 输入密码登录成功

你可能感兴趣的:(ubuntu16.04 安装制定版本的postgreSQL)