postgresql yum install

postgresql yum install

  1. open postgresql yum repo

    1
    2
    [root@dev ~]# rpm -ivh https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-3.noarch.rpm
    [root@dev ~]# make cache
  2. postgresql install

    1
    [root@dev ~]# yum -y install postgresql93-server postgresql93-contrib
  3. postgresql init

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [root@dev ~]# /usr/pgsql-9.3/bin/postgresql93-setup initdb

    [root@dev ~]# tail -1 /etc/passwd
    postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash

    [root@dev ~]# ls -l /var/lib/pgsql/9.3/
    total 8
    drwx------ 2 postgres postgres 6 May 10 07:25 backups
    drwx------ 16 postgres postgres 4096 May 22 11:07 data
    -rw------- 1 postgres postgres 1330 May 22 11:04 initdb.log
  4. postgresql 修改配置文件

    1
    2
    3
    [root@dev ~]# vim /var/lib/pgsql/9.3/data/postgresql.conf
    listen_addresses = '*'
    port = 5432
  5. postgresql 启动

    1
    2
    3
    [root@dev ~]# systemctl start postgresql-9.3
    [root@dev ~]# systemctl status postgresql-9.3
    [root@dev ~]# systemctl enable postgresql-9.3
  6. postgresql 登录,修改密码

    1
    2
    3
    4
    [root@dev ~]# su - postgres
    -bash-4.2$ psql -U postgres
    postgres=# alert user postgres with password 'postgres'
    postgres-# \q