1 添加用户 创建目录
useradd postgres -d /usr/local/pgsql
passwd postgres
mkdir /usr/local/pgsql/
mkdir /usr/local/pgsql/data
chown -R postgres /usr/local/pgsql
chown postgres /usr/local/pgsql/data
2 设置环境变量
vi /etc/profile
export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/pgsql/bin:$PATH
export PGDATA=/usr/local/pgsql/data
export MANPATH=$MANPATH:/usr/local/pgsql/man
3 安装
./configure –prefix=/usr/local/pgsql ;make;make install
4 初始化数据库
su postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
5 添加开机自启动
su root
chmod a+x /postgresql-8.1.9 (postgresql 解压目录)/contrib/start-scripts/linux
cp /tmp/postgresql-8.1.9/contrib/start-scripts/linux /etc/init.d/postgresql
chkconfig –add postgresql
reboot
6 换数据库用户postgres 的密码
psql template1 或者 psql -U postgres
然后
ALTER USER postgres WITH PASSWORD ‘password’;
7 添加外部的访问连接, 在pg_hba.conf 加上
host all all 0.0.0.0/0 trust
修改postgresql.conf
listen_addresses = ‘*’
启动
/usr/local/pgsql/bin/postmaster -i -D /usr/local/pgsql/data &
or
/usr/local/pgsql/bin/pg_ctl -i -D /usr/local/pgsql/data -l logfile start
关闭 kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`
是了,我来这里就只能总结一下了,
Linux下,postgresql.conf pg_hba.conf 都是放在$PG_DATA 目录下,也就是一般的…../data 目录下