- 安装
apt-get install postgresql-11
- 配置外网访问
- 编辑/etc/postgresql/11/main/pg_hba.conf
把
# IPv4 local connections:
host all all 127.0.0.1/32 md5修改成
host all all 0.0.0.0/0 md5
这个文档上面有介绍,0.0.0.0/0表示允许所有ip
- 编辑/etc/postgresql/11/main/postgresql.conf
把
#——————————————————————————
# CONNECTIONS AND AUTHENTICATION
#——————————————————————————# – Connection Settings –
# listen_addresses = ‘localhost’ # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to ‘localhost’; use ‘*’ for all
# (change requires restart)
修改为listen_addresses = ‘*’
把注释去掉,改localhost为星号。文档已经说了,默认是监听本地,如果需要监听其他连接,改成星号(*),表示监听所有,需要重启服务或系统
- 编辑/etc/postgresql/11/main/pg_hba.conf
- 设置管理数据库密码
#进入postgres默认用户 sudo su - postgres #进入数据库 psql #修改密码 \password postgres
- 启动
sudo service postgresql start 或者 sudo pg_ctlcluster 11 main start
- 卸载
sudo apt-get purge postgresql*