System: centos6.4 Installation postgresql9.3
(firewall needs to open port 5432)
Add Yum Source
Yum Install-y http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
Installing PostgreSQL
Yum install-y postgresql93-server Postgresql93-contrib
Change the default installation directory to/data/pgsql (optional, default to/var/lib/postgres)
vim/etc/init.d/postgresql-9.3
Change
Pgdata=/data/pgsql/9.3/data
Pglog=/data/pgsql/9.3/pgstartup.log
pguplog=/data/pgsql/$PGMAJORVERSION/pgupgrade.log
Initializing the database
Service postgresql-9.3 Initdb
Chown Postgres.postgres/data/pgsql
VIM/ETC/PASSWD (change postgres user home directory)
Change
Postgres:x:26:26:postgresqlserver:/data/pgsql:/bin/bash
Add an accessible network segment
#vim/data/pgsql/9.3/data/pg_hba.conf (allow the following network segment IP login)
Host all 192.168.1.0/24 Md5host all 192.168.2.0/24 MD5
Change the Listening address
#vim/data/pgsql/9.3/data/postgresql.conf (monitor changed to *)
listen_addresses = ' * '
#service postgresql-9.3 Start (Start database)
#su-postgres
$createuser--help (view new user help) $createuser-s root create Superuser root (optional)-bash-4.1$ psqlpsql (9.3.2) Type "Help" for Help.pos tgres=# \du List of roles Role name | Attributes | Member of-----------+------------------------------------------------+-----------Postgres | Superuser, create role, create DB, Replication | {} root | Superuser, create role, create DB | {}
Create a mydb library and give normal user test all permissions to MyDB
$createdb mydb (Create a database named MyDB) $createuser test (Create a normal user test) $psqlpostgres =# ALTER user test with password ' test '; (Change the password for the test user is test) postgres= #grante all on the database mydb to test;postgres=# \q
Reference:
http://jianlee.ylinux.org/Computer/Server/postgresql%E6%95%B0%E6%8D%AE%E5%BA%93%E5%85%A5%E9%97%A8.html