1.添加PostgreSQL Yum存储库

sudo yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

2.安装PostgreSQL Server和客户端软件包

sudo yum -y install postgresql11-server postgresql11

3.初始化数据库并启用自动启动

# 初始化
sudo /usr/pgsql-11/bin/postgresql-11-setup initdb
# 启动
sudo systemctl start postgresql-11
# 设置开机自启动
sudo systemctl enable postgresql-11
# 下面这两个配置是关于防火墙的(我没有用到)
sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload

4.启用远程访问PostgreSQL(作用是可以通过公网连接你的数据库,前提是你有公网ip)

# 我的路径是这样的
vi /var/lib/pgsql/11/data/postgresql.conf
# 修改
listen_addresses = '*'
# 我的路径是这样的
sudo vim /var/lib/pgsql/11/data/pg_hba.conf
# 修改
host all all 127.0.0.1/32 md5
# 添加
host all all 0.0.0.0/0 trust
# 重启
sudo systemctl restart postgresql-11

5.设置PostgreSQL管理员用户的密码(一定要按照这种格式配置用户名和密码)

sudo su - postgres
psql -c "alter user 用户名 with password '密码'"

需要注意,如果是云服务器,需要打开对应端口。我就吃了这个亏,折腾了很长时间。

最后,如果问题,请留言。

最新文章

  1. ubuntu 14.10 lts 64-bits环境下使用Android Studio
  2. Apache Shiro系列一,概述 —— 初识
  3. Issue 4:分布式的基础性问题
  4. c# equals与==
  5. JS-slider.js实现鼠标拖动滑块控制取值特效
  6. cocos2d内存管理
  7. Linux Shell 04 数字/字符串/文件测试
  8. UIImage加载图片的两种方法区别
  9. nginx配置-http和https
  10. 终极解决方案:windows10开机黑屏,死机
  11. 解密-神秘的 RunLoop
  12. 02-UIKit控件、MVC
  13. SQL常用语句(二)
  14. [Swift]LeetCode64. 最小路径和 | Minimum Path Sum
  15. blfs(systemd版本)学习笔记-构建google-chrome浏览器
  16. Linux 查看磁盘使用情况
  17. Activiti手动执行的应用(UserTask)
  18. c++官方文档-模版函数和重载
  19. POST与GET请求的区别
  20. java Html 转 PDF

热门文章

  1. python学习Day05--字典
  2. Grevl旅游注册的初步界面,以源代码和运行图片展示
  3. python学习记录(八)
  4. Codeforces_842
  5. eclipse新下载,安装和配置
  6. python练习——第0题
  7. 【TensorFlow】TensorFlow基础 —— 模型的保存读取与可视化方法总结
  8. pytorch之 CNN
  9. LVS 部署
  10. linux shell实用常用命令