centos7安装posgresql

  1. 安装

    #安装源
    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
    # 安装 PostgreSQL centos7 上安装更高版本缺依赖,比较麻烦
    sudo yum install -y postgresql14-server
    
    # 初始化数据库
    sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
    sudo systemctl enable postgresql-14
    sudo systemctl start postgresql-14
    
  2. 修改用户名密码

    //切换用户
    su postgres
    
    //切换SQL模式
    psql
    
    //修改密码
    alter user postgres with password 'postgres';
    
    // 退出
    \q
    
  3. 允许外部连接

    cd /var/lib/pgsql/14/data/
    
    # vi postgresql.conf ,找到listen_addresses改成*
    listen_addresses = '*'
    
    
    #vi pg_hba.conf,最后一行添加,允许任意主机连接
    host    all             all             0.0.0.0/0               scram-sha-256
    
    
    
    
  4. 退出当前账号

    exit
    
  5. 重启 服务

    systemctl restart postgresql-14
    
    #开机自启动
    systemctl enable postgresql-14
    
  6. 远程连接
    image-20240206205009016

posted on   zhangyukun  阅读(57)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示