Skip to content

Instantly share code, notes, and snippets.

@ericchen
Created February 27, 2016 15:09
Show Gist options
  • Save ericchen/e6650d4f78f56963f7a7 to your computer and use it in GitHub Desktop.
Save ericchen/e6650d4f78f56963f7a7 to your computer and use it in GitHub Desktop.
在debian 7 wheezy上安装postgresql-9.4

添加源并安装

  1. vi /etc/apt/sources.list.d/pgdg.list
  2. 添加下面内容到文件:deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
  3. 添加签名key: wget http://www.postgresql.org/media/keys/ACCC4CF8.asc, apt-key add ACCC4CF8.asc
  4. 更新源: apt-get update
  5. 安装: sudo apt-get install postgresql-9.4
  6. 配置验证方式: sudo vi /etc/postgresql/9.4/main/pg_hba.conf 将peer改成md5, 然后重启: sudo service postgresql restart

配置数据库

  1. 登录数据库: sudo -u postgres psql template1
  2. 创建用户名: CREATE USER dbuser WITH PASSWORD 'password';
  3. 创建数据库: CREATE DATABASE db_production OWNER dbuser;
  4. 分配权限: GRANT ALL PRIVILEGES ON DATABASE db_production to dbuser;

##参考链接

  1. http://www.pontikis.net/blog/postgresql-9-debian-7-wheezy
  2. https://help.ubuntu.com/stable/serverguide/postgresql.html
  3. http://www.ruanyifeng.com/blog/2013/12/getting_started_with_postgresql.html
  4. http://www.postgresql.org/download/linux/debian/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment