参考:http://blog.csdn.net/lk10207160511/article/details/50359549##1
1、检查本机是否安装 PostgreSQL
$ sudo rpm -aq | grep postgresql
2、从仓库中安装 PostgresSQL
搜索包名:
$ yum search postgresql
列出包名,例如可能有:
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
安装:
$ sudo yum install postgresql postgresql-server
验证:
$ rpm -qa | grep postgresql
3、初始化数据库
查找命令:
$ 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、启动服务并设置为开机启动
$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql
5、开放防火墙端口
$ sudo firewall-cmd –permanent –add-port=5432/tcp
$ sudo firewall-cmd –permanent –add-port=80/tcp
$ sudo firewall-cmd –reload
6、为用户postgres修改密码
$ sudo passwd postgres
7、以用户postgres登录并访问数据库
$ su – postgres
Last login: Wed Mar 1 09:59:22 CST 2017 on pts/1
-bash-4.2$ psql
psql (9.2.18)
Type “help” for help.
postgres=#
至此,PostgreSQL安装成功。