vi /etc/apt/sources.list.d/pgdg.list
- 添加下面内容到文件:
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
- 添加签名key:
wget http://www.postgresql.org/media/keys/ACCC4CF8.asc, apt-key add ACCC4CF8.asc
- 更新源:
apt-get update
- 安装:
sudo apt-get install postgresql-9.4
- 配置验证方式:
sudo vi /etc/postgresql/9.4/main/pg_hba.conf
将peer改成md5, 然后重启:sudo service postgresql restart
- 登录数据库:
sudo -u postgres psql template1
- 创建用户名:
CREATE USER dbuser WITH PASSWORD 'password';
- 创建数据库:
CREATE DATABASE db_production OWNER dbuser;
- 分配权限:
GRANT ALL PRIVILEGES ON DATABASE db_production to dbuser;
##参考链接