Reference: http://blog.csdn.net/lk10207160511/article/details/50359549# #1
1. Check if PostgreSQL is installed on this machine
$ sudo rpm-aq | grep postgresql
2. Install Postgressql from the warehouse
Search Package Name:
$ Yum Search PostgreSQL
List the package names, for example, you might have:
Postgresql.i686:PostgreSQL Client Programs
Postgresql.x86_64:PostgreSQL Client Programs
Postgresql-server.x86_64:the programs needed to create and run a PostgreSQL server
Installation:
$ sudo yum install PostgreSQL postgresql-server
Verify:
$ Rpm-qa | grep postgresql
3. Initialize the database
Find command:
$ rpm-ql postgresql-server | grep setup
/usr/bin/postgresql-setup
/usr/share/man/man1/postgresql-setup.1.gz
$ sudo postgresql-setup initdb
Initializing database ... Ok
4. Start the service and set it to boot
$ sudo systemctl enable PostgreSQL
$ sudo systemctl start PostgreSQL
5. Open firewall port
$ sudo firewall-cmd--permanent --add-port=5432/tcp
$ sudo firewall-cmd--permanent --add-port=80/tcp
$ sudo firewall-cmd--reload
6. Change password for user Postgres
$ sudo passwd postgres
7. Log in with user Postgres and access the database
$ su-postgres
Last login:wed Mar 1 09:59:22 CST on PTS/1
-bash-4.2$ psql
Psql (9.2.18)
Type ' help ' for help.
postgres=#
At this point, PostgreSQL was installed successfully.
CentOS 7 Installation PostgreSQL