@ECHO OFF
REM The script sets environment variables helpful for PostgreSQL
set PGHOME=d:\pgsql
SET PATH="%PGHOME%\bin";%PATH%
SET PGDATA=%PGHOME%\data
SET PGDATABASE=postgres
SET PGPORT=5432为方便,你可以将其设置到用户环境变量当中。以下是系统初始化以及创建数据库的基本过程:
1. initdb --no-locale -E UTF-8 -D d:\pgsql\data
2. D:\pgsql>pg_ctl -D "d:/pgsql/data" -l logfile.log start
server starting
3. D:\pgsql\bin>createuser spring
Shall the new role be a superuser? (y/n) y
4. D:\pgsql\bin>createdb iihero
5. install the odbc driver:
regedit odbc_reg.reg
5. D:\pgsql>psql iihero
psql (9.1.3)
Type "help" for help.
iihero=# create table t(id varchar(32));
CREATE TABLE
iihero=# \encoding gbk;
iihero=# insert into t values('中国');
INSERT 0 1
iihero=# select * from t;
id
------
中国
(1 row)
iihero=# create table foo(id bigint);
CREATE TABLE
iihero=# insert into foo select * from generate_series(1, 100000);
INSERT 0 100000
iihero=# select oid from pg_database where datname='iihero';
oid
-------
16385
(1 row)
6.iihero=# \q
D:\pgsql>pg_ctl stop
waiting for server to shut down.... done
server stopped 二、第二种方式是源码包安装方式
从下面找你想编译的source:
http://www.postgresql.org/ftp/source/进入一个具体的版本分支, 以最新的9.2.1为例,你可以进入v9.2.1目录,下载源码:postgresql-9.2.1.tar.gz
1.如果是linux平台,确保linux平台有完整的gcc/g++/make/libtool开发包,直接linux下解压,然后进入源码目录,执行./configure--prefix=<你要安装的目录>
make
makeinstall
install完以后,配置几个简单的环境变量到当前用户的shellprofile里头即可。
如: