Ubuntu下的Postgresql 10(特定版本)环境配置

1.Postgresql官网获取特定版本的储存库。

 Ubuntu 默认包含 PostgreSQL。要在 Ubuntu 上安装最新的 PostgreSQL, 使用命令:

sudo apt install postgresql

自动存储库配置:

sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

要手动配置 Apt 存储库,按照下列步骤操作:

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt install postgresql-10
2.Postgresql创建账号、密码、赋予权限。

 运行系统用户,进入Postgre客户端:

sudo -u postgres psql

创建用户“sde”并设置密码:

create user sde with password '123456';

赋予用户“sde”权限:

create database sde owner sde;
grant all privileges on database sde to sde;
3.允许Postgresql远程数据连接

进入Postgresql的安装目录,修改配置文件:pg_hba.conf和postgresql.conf

cd /etc/postgresql/10/main
sudo gedit pg_hba.conf
sudo gedit postgresql.conf

pg_hba.conf中在“# IPv4 local connections:”后加入

host    all             all             0.0.0.0/0                trust

postgresql.conf中在“listen_addresses” 后面的=改为*。如 listen_addresses = '*'。若listen_addressde前面有#,将代码注释掉了的,需要去掉#。

修改完这两个文件后需要重启服务:

sudo service postgresl restart

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值