Install Postgresql On Centos

Today, I want to try a new DB-postgresql and prepare to install it on my server.There some problems stand in the way during I install postgresql.

resource

At the begining, I tried to find some commands to download and install postgresql.Unfortunately, the resource were not found.Then I started to find resource on the Internet.I recommend a website to readers:

https://yum.postgresql.org/9.2/redhat/rhel-6-i386/

I download version 9.2.18.
这里写图片描述

install

You should install the packages in order.You can use rpm and choose method -ivh.

  1. postgresql92-libs-9.2.18-1PGDG.rhel6.i686.rpm
  2. postgresql92-9.2.18-1PGDG.rhel6.i686.rpm
  3. postgresql92-server-9.2.18-1PGDG.rhel6.i686.rpm
  4. postgresql92-contrib-9.2.18-1PGDG.rhel6.i686.rpm

lack of dependencies

When I use ‘rpm’ to install postgresql, the command line prompts:
libcrypto.so.10 is needed by……
libssl.so.10 is needed by……
Absolutely, my system lack some files.I try many methods but failed.Then I try to use ‘yum’.I succeed.

start and init

start

1
# /etc/init.d/postgresql-9.2 start

when we start postgresql first time, command line will prompts us:

1
/var/lib/pgsql……[FAILED]

init

1
# service postgresql-9.2 initdb

start

1
# service postgresql-9.2 start

add postgresql server into boots

1
chkconfig postgresql-9.2 on

change password

1
2
3
# su - postgres
$ psql
# ALTER USER postgres WITH PASSWORD 'postgres'