1)安装参照(http://www.if-not-true-then-false.com/2012/install-postgresql-on-fedora-centos-red-hat-rhel/) sql
经常使用查询数据库
select current_database() |
经常使用命令centos
\dn 数据库列表post \du 当前数据库的用户列表spa |
chkconfig --level 235 postgresql-9.4 on2) 启动数据库服务
postgresql
service postgresql-9.4 startcode
service postgresql-9.4 stopget
3) 建立用户及远程链接
it
sudo -u postgres psqlio create user twdpm with password 'twdpm' create database test; grant all privileges on database test to twdpm; |
4)配置
配置/var/lib/pgsql/9.4/data/postgresql.conf
配置/var/lib/pgsql/9.4/data/pg_hba.conf
主要是配置用户的访问权限和访问的主机控制。
5)链接到数据库
psql -h 192.168.0.103 -d test -U twdpm
退出数据库链接 \q
6)建立数据库的两种方式
create database atm with encoding='UTF8' OWER=user1 CONNECTION LIMIT=25;
createdb -h 192.168.0.103 -U postgres testdb2;
7)删除数据库
drop database test;
查询当前建立的数据库
select datname from pg_database where datistemplate = false;
建立数据库的schema的两种放式
create schema employee;
create schema employee authorization user1;