下载并解包
$ tar zxvf postgresql-8.2.4.tar.gz
$ cd postgresql-8.2.4
配置
$ ./configure --prefix=/usr/local/pgsql-8.2.4
...
config.status: linking ./src/makefiles/Makefile.linux to src/Makefile.port
编译
$ make
...
All of PostgreSQL successfully made. Ready to install.
测试
$ make check
...
=======================
All 103 tests passed.
=======================
安装(root)
# su -
# groupadd postgresql
# useradd -g postgresql postgresql
# cd <安装目录>
# make install
...
PostgreSQL installation complete.
# cd /usr/local
# ln -s pgsql-8.2.4 pgsql
# mkdir /usr/local/pgsql/data
# cd /usr/local/pgsql
# chown postgresql.postgresql data
初始化数据库目录(postgresql)
# su - postgresql
$ cd /usr/local/pgsql/bin
设置locale为C,并且template1编码为UNICODE,使数据库支持中文
$ ./initdb --locale=C -E UNICODE -D ../data/
...
Success. You can now start the database server using:
./postgres -D ../data
or
./pg_ctl -D ../data -l logfile start
配置环境变量及日志文件(root)
$ (^d)
# vi /etc/profile
PATH=/usr/local/pgsql/bin:$PATH
PGDATA=/usr/local/pgsql/data
使环境变量生效(或重启操作系统)
# export PGDATA=/usr/local/pgsql/data
# touch /var/log/pgsql.log
# chown postgresql.postgresql /var/log/pgsql.log
修改配置文件(postgresql)
$ su - postgresql
$ cd /usr/local/pgsql/data
修改配置使监听生效,取消以下两行的注释
$ vi postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
启动数据库(postgresql)
$ cd /usr/local/pgsql/bin
$ ./postmaster -D /usr/local/pgsql/data > /var/log/pgsql.log 2>&1 &
$ cat /var/log/psql.log
LOG: checkpoint record is at 0/42C424
LOG: redo record is at 0/42C424; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 0/593; next OID: 10820
LOG: next MultiXactId: 1; next MultiXactOffset: 0
LOG: database system is ready
创建数据库dm
$ ./createdb dm
CREATE DATABASE
创建用户
$ ./createuser -A -D -E -P dm
Enter password for new role: 123456
Enter it again: 123456
Shall the new role be allowed to create more new roles? (y/n) y
CREATE ROLE
使用psql
$ ./psql -d dm -U dm
Welcome to psql 8.2.4, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
dm=> \q
*在psql中若需要使用中文,先发送:
dm=> set client_encoding to 'gbk';
配置数据库自启动脚本(root)
$ (^d)
# cd /etc/rc.d/init.d
# cp (安装目录)/postgresql-8.2.4/contrib/start-script/linux postgresql
# chmod +x postgresql
# vi postgresql
prefix=/usr/local/pgsql
PGDATA="/usr/local/pgsql/data"
PGUSER=postgresql
PGLOG="/var/log/pgsql.log"
# chkconfig --add postgresql
重启数据库
# /etc/rc.d/init.d/postgresql restart
=== 配置完成 ===
分享到:
相关推荐
redhat linux安装使用指南 redhat linux安装使用指南
RedHat Linux安装图解RedHat Linux安装图解RedHat Linux安装图解RedHat Linux安装图解
Redhat Linux 5.8 安装手册
RedHat Linux安装及使用指南 是初学者使用
redhat linux安装jdk 1.7
RedHat Linux安装及使用指南 安装及使用指南
vmware与redhat linux 7.3安装过程和步骤,描述比较详细且步骤比较清晰……方便理解
大神总结的RedHat Linux操作系统安装规范 大神总结的RedHat Linux操作系统安装规范 大神总结的RedHat Linux操作系统安装规范
RedHat Linux9.0安装图解 全程图解
RedHat Linux安装图解.pdf
比较详细的 RedHat Linux 安装手册
在Redhat下安装Oracle10g.pdf 在RedHat Enterprise Linux 5下安装JDK.doc REdHat Linux 5 tomcat 的安装及环境的配置.doc
RedHat+Linux安装图解.pdf
U盘装RedHat linux系统图文教程,不用刻光盘了,就U盘装系统。简单。
RedHat Linux安装Oracle10g
Redhat linux安装Oracle12c