Home > Database > Mysql Tutorial > postgresql安装配置简单操作

postgresql安装配置简单操作

WBOY
Release: 2016-06-07 14:53:55
Original
1250 people have browsed it

postgresql安装配置简单操作 1、下载postgresql最新版: http://www.postgresql.org/ftp/source/ 2、解压文件: www.2cto.com tar zxvf postgresql-8.3.7.tar.gz cd postgresql-8.3.7 3、配置: ./configure --prefix=/usr/local/pgsql 4、编译: make 5、安


postgresql安装配置简单操作

 

1、下载postgresql最新版:

http://www.postgresql.org/ftp/source/

2、解压文件:  www.2cto.com  

tar zxvf postgresql-8.3.7.tar.gz

cd postgresql-8.3.7

 

3、配置:

./configure --prefix=/usr/local/pgsql

 

4、编译:

make

 

5、安装:

make install

 

6、创建用户组和用户:

groupadd postgres

useradd -g postgres postgres

 

7、创建数据库库文件存储目录、给postgres赋予权限:

mkdir /usr/local/pgsql/data

cd /usr/local/pgsql

chown postgres.postgres data

 

8、初始化数据库目录:

切换用户

   su - postgresql

  www.2cto.com  

初始化数据

   /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

 

启动数据库

   /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data

 

9、配置监听地址和端口:

vi /usr/local/pgsql/data/postgresql.conf

取消以下两行的注释

   listen_addresses = '*'

 

   port = 5432

 

10、允许远程连接:

vi /usr/local/pgsql/data/pg_hba.conf

添加

   host all all 192.168.1.0/24 trust

 

   每项的具体意思在配置文件中有详细说明

配置iptables让远程主机能访问:

   vi /etc/sysconfig

   添加

      -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

   service iptables restart

  www.2cto.com  

11、让postgresql数据库随系统启动而启动:

将启动脚本拷贝到/etc/init.d/目录下,具体执行如下命令:

cd /etc/rc.d/init.d

cp (第一步解压的安装文件目录)/postgresql-8.3.7/contrib/start-scripts/linux postgresql

chmod +x postgresql

vi postgresql

   prefix=/usr/local/pgsql

   PGDATA="/usr/local/pgsql/data"

   PGUSER=postgres

   PGLOG="/var/log/pgsql.log"

 

   chkconfig --add postgresql

启动数据库:

   service postgresql start

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template