postgresql安装及配置



安装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官网














發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章