postgresql9.3 ubuntu下安装之后的简单配置

  1. 安装就不说了,反正如果直接apt-get目前是拿不到最新的版本的,直接apt-get install postgresql-9.3会告诉你找不到,得到http://www.postgresql.org/download/linux/ubuntu/去看,
  2. 首先要创建一个文件:/etc/apt/sources.list.d/pgdg.list,需要root权限,追加一行内容
  3. deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
  4. 然后导入从https://www.postgresql.org/media/keys/ACCC4CF8.asc导入repository key
  5. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql-9.3 pgadmin3
  6. 安装完毕要配置了,#sudo -u postgres psql(用postgres登录psql)
  7. postgres#password postgres(在psql环境为postgres用户指定密码,退出是q)
  8. 在postgres环境中 select name, setting from pg_settings where category="File Locations";得到配置文件所在的目录
  9. 修改配置文件postgresql.conf: listen_address=′*′ password_encryption=on
  10. 确认pg_hba.conf: host all all 127.0.0.1/32 md5没有被注释
  11. sudo service postgresql restart
  12. 配置完成
ysql忘记root密码后还是需要一点手脚的,发觉postgresql基本没啥特别之处 修改pg_hba.conf中的host all all 127.0.0.1/32 md5 为host all all 127.0.0.1/32 trust然后sudo -u postgres psql直接就进去了