linux安装postgreSQL

来源:互联网 发布:amtemu mac用不了 编辑:程序博客网 时间:2024/05/16 06:12

进入安装目录

cd /opt/postgreSQL

解压

tar zxvf postgresql-9.3.2.tar.gz

cd postgresql-9.3.2

配置

./configure --prefix=/opt/postgreSQL --with-perl--with-python --with-libxml --with-libxslt

编译安装

make (会需要几分钟的时间)

make install

安装contrib目录下的一些工具,是第三方组织的一些工具代码,建议安装

cd /opt/postgreSQL/postgresql-9.3.2/contrib

make

make install

创建用户和组

groupadd postgres

useradd -g postgres postgres

 

建postgres数据库的目录并授权

mkdir -p /var/postgresql/data

chown postgres:postgres /var/postgresql/*

chown postgres:postgres /usr/local/postgresql/*

chmod -R 775 /var/postgresql/*

su - postgers

#初始化数据库

initdb -D /var/postgresql/data

 

ostgresql服务管理
启动:
pg_ctl start -D /data/pg/data
 
重启:
pg_ctl restart -D /data/pg/data
停止:
pg_ctl stop -D /data/pg/data
强制重启:
pg_ctl restart -D /data/pg/data -m f
强制停止:
pg_ctl stop -D /data/pg/data -m f

#修改客户端认证配置文件pg_hba.conf,将需要远程访问数据库的IP地址或地址段加入该文件

vi /var/postgresql/data/pg_hba.conf

#在文件的最下方加上下面的这句话

host    all         all         0.0.0.0/0             trust

 

查看运行状态:

[postgres@wwll data]$ pg_ctl status -D/var/postgresql/data
pg_ctl: server is running (PID: 15182)
/opt/postgreSQL/bin/postgres "-D" "/var/postgresql/data"

0 0
原创粉丝点击