Linux有网络下安装pgsql

进入网站 PostgreSQL: Downloads 选择您要操作的系统,我这里使用centos7操作系统,且一下都是以此为演示。

1、选择信息并复制脚本

2、关闭防火墙并设置开机不启用


[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service

3、登录centos操作系统粘贴复制的脚本信息,执行信息如下;

[root@localhost ~]# sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
已加载插件:fastestmirror
pgdg-redhat-repo-latest.noarch.rpm                                                                                                  | 8.6 kB  00:00:00
正在检查 /var/tmp/yum-root-AxNpNu/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-28.noarch
/var/tmp/yum-root-AxNpNu/pgdg-redhat-repo-latest.noarch.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 pgdg-redhat-repo.noarch.0.42.0-28 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================
 Package                               架构                        版本                         源                                                    大小
===========================================================================================================================================================
正在安装:
 pgdg-redhat-repo                      noarch                      42.0-28                      /pgdg-redhat-repo-latest.noarch                       13 k

事务概要
===========================================================================================================================================================
安装  1 软件包

总计:13 k
安装大小:13 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : pgdg-redhat-repo-42.0-28.noarch                                                                                                        1/1
  验证中      : pgdg-redhat-repo-42.0-28.noarch                                                                                                        1/1

已安装:
  pgdg-redhat-repo.noarch 0:42.0-28

完毕!
[root@localhost ~]# sudo yum install -y postgresql12-server
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
base                                                                                                                                | 3.6 kB  00:00:00
extras                                                                                                                              | 2.9 kB  00:00:00
pgdg-common/7/x86_64/signature                                                                                                      |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg-common/7/x86_64/signature                                                                                                      | 2.9 kB  00:00:00 !!!
pgdg10/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg10/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
pgdg11/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg11/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
pgdg12/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg12/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
pgdg13/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg13/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
pgdg14/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg14/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
pgdg15/7/x86_64/signature                                                                                                           |  198 B  00:00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
pgdg15/7/x86_64/signature                                                                                                           | 3.6 kB  00:00:00 !!!
updates                                                                                                                             | 2.9 kB  00:00:00
(1/17): base/7/x86_64/group_gz                                                                                                      | 153 kB  00:00:00
(2/17): extras/7/x86_64/primary_db                                                                                                  | 249 kB  00:00:00
(3/17): pgdg10/7/x86_64/group_gz                                                                                                    |  245 B  00:00:01
(4/17): base/7/x86_64/primary_db                                                                                                    | 6.1 MB  00:00:02
(5/17): pgdg11/7/x86_64/group_gz                                                                                                    |  245 B  00:00:01
(6/17): pgdg-common/7/x86_64/primary_db                                                                                             | 165 kB  00:00:02
(7/17): pgdg13/7/x86_64/group_gz                                                                                                    |  246 B  00:00:00
(8/17): pgdg10/7/x86_64/primary_db                                                                                                  | 400 kB  00:00:02
(9/17): pgdg14/7/x86_64/group_gz                                                                                                    |  244 B  00:00:00
(10/17): pgdg11/7/x86_64/primary_db                                                                                                 | 453 kB  00:00:01
(11/17): pgdg12/7/x86_64/primary_db                                                                                                 | 339 kB  00:00:01
(12/17): pgdg14/7/x86_64/primary_db                                                                                                 | 159 kB  00:00:00
(13/17): pgdg12/7/x86_64/group_gz                                                                                                   |  245 B  00:00:01
(14/17): pgdg13/7/x86_64/primary_db                                                                                                 | 246 kB  00:00:00
(15/17): pgdg15/7/x86_64/group_gz                                                                                                   |  246 B  00:00:00
(16/17): pgdg15/7/x86_64/primary_db                                                                                                 |  70 kB  00:00:00
(17/17): updates/7/x86_64/primary_db                                                                                                |  18 MB  00:00:05
正在解决依赖关系
--> 正在检查事务
---> 软件包 postgresql12-server.x86_64.0.12.13-1PGDG.rhel7 将被 安装
--> 正在处理依赖关系 postgresql12-libs(x86-64) = 12.13-1PGDG.rhel7,它被软件包 postgresql12-server-12.13-1PGDG.rhel7.x86_64 需要
--> 正在处理依赖关系 postgresql12(x86-64) = 12.13-1PGDG.rhel7,它被软件包 postgresql12-server-12.13-1PGDG.rhel7.x86_64 需要
--> 正在处理依赖关系 libpq.so.5()(64bit),它被软件包 postgresql12-server-12.13-1PGDG.rhel7.x86_64 需要
--> 正在处理依赖关系 libicuuc.so.50()(64bit),它被软件包 postgresql12-server-12.13-1PGDG.rhel7.x86_64 需要
--> 正在处理依赖关系 libicui18n.so.50()(64bit),它被软件包 postgresql12-server-12.13-1PGDG.rhel7.x86_64 需要
--> 正在检查事务
---> 软件包 libicu.x86_64.0.50.2-4.el7_7 将被 安装
---> 软件包 postgresql12.x86_64.0.12.13-1PGDG.rhel7 将被 安装
---> 软件包 postgresql12-libs.x86_64.0.12.13-1PGDG.rhel7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================
 Package                                     架构                           版本                                      源                              大小
===========================================================================================================================================================
正在安装:
 postgresql12-server                         x86_64                         12.13-1PGDG.rhel7                         pgdg12                         5.1 M
为依赖而安装:
 libicu                                      x86_64                         50.2-4.el7_7                              base                           6.9 M
 postgresql12                                x86_64                         12.13-1PGDG.rhel7                         pgdg12                         1.6 M
 postgresql12-libs                           x86_64                         12.13-1PGDG.rhel7                         pgdg12                         376 k

事务概要
===========================================================================================================================================================
安装  1 软件包 (+3 依赖软件包)

总下载量:14 M
安装大小:54 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/base/packages/libicu-50.2-4.el7_7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY MB/s | 5.3 MB  00:00:04 ETA
libicu-50.2-4.el7_7.x86_64.rpm 的公钥尚未安装
(1/4): libicu-50.2-4.el7_7.x86_64.rpm                                                                                               | 6.9 MB  00:00:01
警告:/var/cache/yum/x86_64/7/pgdg12/packages/postgresql12-libs-12.13-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY00:00:03 ETA
postgresql12-libs-12.13-1PGDG.rhel7.x86_64.rpm 的公钥尚未安装
(2/4): postgresql12-libs-12.13-1PGDG.rhel7.x86_64.rpm                                                                               | 376 kB  00:00:02
(3/4): postgresql12-server-12.13-1PGDG.rhel7.x86_64.rpm                                                                             | 5.1 MB  00:00:06
(4/4): postgresql12-12.13-1PGDG.rhel7.x86_64.rpm                                                                                    | 1.6 MB  00:00:12
-----------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                       1.1 MB/s |  14 MB  00:00:12
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 检索密钥
导入 GPG key 0x442DF0F8:
 用户ID     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 指纹       : 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 软件包     : pgdg-redhat-repo-42.0-28.noarch (@/pgdg-redhat-repo-latest.noarch)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-9.2009.0.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libicu-50.2-4.el7_7.x86_64                                                                                                             1/4
  正在安装    : postgresql12-libs-12.13-1PGDG.rhel7.x86_64                                                                                             2/4
  正在安装    : postgresql12-12.13-1PGDG.rhel7.x86_64                                                                                                  3/4
  正在安装    : postgresql12-server-12.13-1PGDG.rhel7.x86_64                                                                                           4/4
  验证中      : postgresql12-libs-12.13-1PGDG.rhel7.x86_64                                                                                             1/4
  验证中      : postgresql12-12.13-1PGDG.rhel7.x86_64                                                                                                  2/4
  验证中      : postgresql12-server-12.13-1PGDG.rhel7.x86_64                                                                                           3/4
  验证中      : libicu-50.2-4.el7_7.x86_64                                                                                                             4/4

已安装:
  postgresql12-server.x86_64 0:12.13-1PGDG.rhel7

作为依赖被安装:
  libicu.x86_64 0:50.2-4.el7_7              postgresql12.x86_64 0:12.13-1PGDG.rhel7              postgresql12-libs.x86_64 0:12.13-1PGDG.rhel7

完毕!
[root@localhost ~]# sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

[root@localhost ~]# sudo systemctl enable postgresql-12
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-12.service to /usr/lib/systemd/system/postgresql-12.service.
[root@localhost ~]# sudo systemctl start postgresql-12

4、开启原创访问

修改 /var/lib/pgsql/12/data/ 下的 postgresql.conf 文件如下信息取消注释并修改值

 修改同级别pg_ident.conf文件改为如下信息

 5、修改登录密码

su postgres

 \password

输入两次密码一致,记录信息如下:


[root@localhost ~]# su postgres
bash-4.2$ psql
could not change directory to "/root": 权限不够
psql (12.13)
Type "help" for help.

postgres=#  \password
Enter new password for user "postgres":
Enter it again:

6、重启数据库 systemctl restart postgresql-12

7、客户端连接

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值