centos6离线安装postgresql12

准备工作

下载安装包

点击去官网下载

百度网盘下载:

链接: https://pan.baidu.com/s/1mK7adSDSEZMyKvDSwg-v3A 
提取码: ipaf 

上传服务器

在这里插入图片描述

开始安装

依次执行以下命令,顺便不能错,否则会导致安装失败
[root@localhost install]# rpm -ivh postgresql12-libs-12.3-1PGDG.rhel6.x86_64.rpm
[root@localhost install]# rpm -ivh postgresql12-12.3-1PGDG.rhel6.x86_64.rpm
[root@localhost install]# rpm -ivh postgresql12-server-12.3-1PGDG.rhel6.x86_64.rpm
[root@localhost install]# rpm -ivh postgresql12-contrib-12.3-1PGDG.rhel6.x86_64.rpm

在这里插入图片描述

初始化数据库,第一要在/usr/pgsql-12/bin/目录下
[root@localhost bin]# cd /usr/pgsql-12/bin/
[root@localhost bin]# service postgresql-12 initdb

以上不行的话,执行

[root@localhost bin]# /usr/pgsql-12/bin/postgresql-12-setup initdb
设置开机启动
[root@localhost bin]# chkconfig postgresql-12 on
启动postgresql12数据库
[root@localhost bin]# service postgresql-12 start

在这里插入图片描述

本地登录
[root@localhost bin]# su postgres
bash-4.1$ psql
psql (12.3)
Type "help" for help.
postgres=# 

在这里插入图片描述

修改配 postgresql.conf 、pg_hba.conf

[root@localhost ~]# cd /var/lib/pgsql/12/data
[root@localhost data]# ll
total 132
drwx------. 5 postgres postgres  4096 Jul 14 17:32 base
-rw-------. 1 postgres postgres    30 Jul 14 17:32 current_logfiles
drwx------. 2 postgres postgres  4096 Jul 14 17:32 global
drwx------. 2 postgres postgres  4096 Jul 14 17:32 log
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_commit_ts
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_dynshmem
-rw-------. 1 postgres postgres  4269 Jul 14 17:30 pg_hba.conf
-rw-------. 1 postgres postgres  1636 Jul 14 17:30 pg_ident.conf
drwx------. 4 postgres postgres  4096 Jul 14 17:37 pg_logical
drwx------. 4 postgres postgres  4096 Jul 14 17:30 pg_multixact
drwx------. 2 postgres postgres  4096 Jul 14 17:32 pg_notify
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_replslot
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_serial
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_snapshots
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_stat
drwx------. 2 postgres postgres  4096 Jul 14 17:46 pg_stat_tmp
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_subtrans
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_tblspc
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_twophase
-rw-------. 1 postgres postgres     3 Jul 14 17:30 PG_VERSION
drwx------. 3 postgres postgres  4096 Jul 14 17:30 pg_wal
drwx------. 2 postgres postgres  4096 Jul 14 17:30 pg_xact
-rw-------. 1 postgres postgres    88 Jul 14 17:30 postgresql.auto.conf
-rw-------. 1 postgres postgres 26612 Jul 14 17:30 postgresql.conf
-rw-------. 1 postgres postgres    57 Jul 14 17:32 postmaster.opts
-rw-------. 1 postgres postgres   104 Jul 14 17:32 postmaster.pid
pg_hba.conf修改如下

在这里插入图片描述

postgresql.conf修改如下

在这里插入图片描述

重启服务
[root@localhost data]# service postgresql-12 restart

服务器登录之后创建用户密码
[root@localhost bin]# su postgres
bash-4.1$ psql
psql (12.3)
Type "help" for help.

postgres=# create user root with password 'datahome123';
CREATE ROLE
postgres=# alter role root login;
ALTER ROLE
postgres=# alter role root superuser createrole createdb;
ALTER ROLE
postgres=# \dt
Did not find any relations.
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 root      | Superuser, Create role, Create DB                          | {}

在这里插入图片描述

使用navicat Premium 远程登录数据库

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值