0
点赞
收藏
分享

微信扫一扫

linux系统yum 安装postgresql

eelq 2022-04-26 阅读 66

1.查看系统版本号(此次操作系统为redhat)

cat /etc/issue,此命令也适用于所有的Linux发行版。

cat /etc/redhat-release,这种方法只适合Redhat系的Linux:

lsb_release -a,即可列出所有版本信息:

  

2.下载安装包

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

3. 安装postgresql

yum install -y postgresql14-server

4.初始化数据库

usr/pgsql-14/bin/postgresql-14-setup initdb 

5.默认启动数据库

sudo systemctl enable postgresql-14

6.启动数据库

sudo systemctl start postgresql-14

 

7.查看postgresql是否安装成功

ps -ef | grep postgres

8.修改数据库密码 

 sudo passwd postgres

9.修改配置文件

cd /var/lib/pgsql/14/data/

vi postgresql.conf 

修改listen_addressses='*';(监听所有ip)

 

 vi pg_hba.conf 

增加一行  host   all  all  0.0.0.0/0  scram-sha-256

 10.连接测试

安装命令参考官网地址PostgreSQL: Linux downloads (Red Hat family)icon-default.png?t=M3K6https://www.postgresql.org/download/linux/redhat/修改postgresql密码

      1.登录PostgreSQL

     sudo -u postgres psql

    2:修改登录PostgreSQL密码

      ALTER USER postgres WITH PASSWORD 'postgres';
    密码postgres要用引号引起来
      命令最后有分号
    3:退出PostgreSQL客户端
    \q
 

 

举报

相关推荐

0 条评论