centos7安装postgreSql11

postgreSql的安装流程官网都已经列出,https://www.postgresql.org/download/linux/redhat/

按照官网给的流程安装:

#安装rpm源
[root@guangzhou src]# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
#安装客户端工具包
[root@guangzhou src]# yum install postgresql11
#安装服务端工具包
[root@guangzhou src]# yum install postgresql11-server
#初始化database
[root@guangzhou src]# /usr/pgsql-11/bin/postgresql-11-setup initdb
Initializing database ... OK
#启动
[root@guangzhou src]# systemctl start postgresql-11
[root@guangzhou src]# systemctl status postgresql-11
● postgresql-11.service - PostgreSQL 11 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; disabled; vendor preset: disabled)
   Active: active (running) since 一 2020-02-10 21:15:40 CST; 6s ago
     Docs: https://www.postgresql.org/docs/11/static/
  Process: 26607 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 26612 (postmaster)
   CGroup: /system.slice/postgresql-11.service
           ├─26612 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/
           ├─26614 postgres: logger
           ├─26616 postgres: checkpointer
           ├─26617 postgres: background writer
           ├─26618 postgres: walwriter
           ├─26620 postgres: autovacuum launcher
           ├─26624 postgres: stats collector
           └─26625 postgres: logical replication launcher

2月 10 21:15:39 guangzhou systemd[1]: Starting PostgreSQL 11 database server...
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.038 CST [26612] LOG:  listening on IPv6 address "::1", port 5432
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.038 CST [26612] LOG:  listening on IPv4 address "127.0....t 5432
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.048 CST [26612] LOG:  listening on Unix socket "/var/ru....5432"
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.058 CST [26612] LOG:  listening on Unix socket "/tmp/.s....5432"
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.078 CST [26612] LOG:  redirecting log output to logging...rocess
2月 10 21:15:40 guangzhou postmaster[26612]: 2020-02-10 21:15:40.078 CST [26612] HINT:  Future log output will appear in..."log".
2月 10 21:15:40 guangzhou systemd[1]: Started PostgreSQL 11 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@guangzhou src]#

   #查看版本

  [root@guangzhou src]# /usr/pgsql-11/bin/psql -V
  psql (PostgreSQL) 11.6


#加入开机启动
#systemctl enable postgresql-11

 

#PostgresSQL安装后会自动创建postgres用户,没有密码
[root@guangzhou src]# su - postgres
#创建用户并设置密码
postgres=# create user test_man with password '123456';
CREATE ROLE
#创建数据库
postgres=# create database test_db owner test_man;
CREATE DATABASE
#赋权
postgres=# grant all privileges on database test_db to test_man;
GRANT


#更改配置
[root@guangzhou src]# vim /var/lib/pgsql/11/data/postgresql.conf
#不限制来访IP
listen_addresses = '*'          # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
#开放端口
port = 5432

#编辑另一个文件,新增配置
[root@guangzhou src]# vim /var/lib/pgsql/11/data/pg_hba.conf
host    all             all             0.0.0.0/0            ident

#重启数据库
[root@guangzhou src]# systemctl restart postgresql-11

使用客户端工具连接测试:

 

posted @ 2020-02-10 21:17  潮起潮落中看星辰大海  阅读(576)  评论(0编辑  收藏  举报