安裝postgresql
1、安裝存儲庫
yum install https://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-7-x86_64/pgdg-centos92-9.2-2.noarch.rpm
2、安裝客戶端包
yum install postgresql92
3、安裝服務端包
yum install postgresql92-server
4、初始化數據庫
/usr/pgsql-9.2/bin/postgresql92-setup initdb
5、啓動數據庫
systemctl enable postgresql-9.2
systemctl start postgresql-9.2
配置數據
1、登錄postgresql, postgresql安裝完成後自動建立postgres用戶
su postgres
bash-4.2$
2、進入postgresql命令行環境
psql
postgres=#
3、配置 pg_hba.conf和postgresql.conf文件是數據庫可以遠程連接
vi /var/lib/pgsql/9.2/data/pg_hba.conf
host all all 0.0.0.0/0 trust
vi /var/lib/pgsql/9.2/data/postgresql.conf
listen_addresses = '*'
查看數據端口Linux下
netstat -a | grep PGSQL
查看當前用戶
select current_user;
查看當前數據庫
select current_database();
查看當前數據庫的表名
select * from pg_tables;
此圖來自postgresql官網