PostgreSQL笔记(一)安装、运行、远程访问
写在前面
PostgreSQL是我们项目组的主要使用数据库,之前使用MySQL。据leader说为了更高的性能,好像也和Akka的使用有关。希望随着自己的学习,可以进一步了解与MySQL的差异(貌似除了开源的特性,功能理念均不同),记录笔记,方便以后查阅。
安装
官网具有详细指导。
环境变量:
vi /etc/bashrc
export PATH="$PATH:/usr/pgsql-9.5/bin"
source /etc/profile
创建数据目录:
initdb -D ~/postgres/data
运行
chown -R postgres /var/run/postgresql
pg_ctl -D /home/postgres/postgres/data -l logfile start
启动远程访问
postgresql.conf中编辑
listen_addresses = '*'
pg_hba.conf中增加
host all all 0.0.0.0/0 md5
重启
pg_ctl restart -D /home/postgres/postgres/data -l logfile
总结
在centos上安装postgres,并将主要步骤记录下来。
注意:运行数据库的用户不能为root,建议创建一个专属用户。
http://www.postgres.cn/docs/9.5/中文手册。