中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 数据库开发 > PostgreSQL
setup PostgreSQL under Windows/Cygwin
作者:未知 时间:2005-09-13 18:57 出处:ChinaUnix.net 责编:chinaitpower
              摘要:setup PostgreSQL under Windows/Cygwin

安装其实很EASY:

步骤:

Install Cygwin 

Start by downloading / installing the latest Cygwin. At http://www.cygwin.com/, you will find lot of little "Install Cygwin Now" icons - click on one of those.

This will start an interactive download. After several steps, you will come to a screen that allows you to select which packages to download. I have the following groups installed for my setup. Note that some of these will be installed by default, and some are interdependent, so when you choose one, another will automatically be selected.

admin->cron (BIN)
admin->cygrunsrv (BIN)
admin->shutdown (BIN)

base->ash (BIN)
base->bash (BIN)
base->cygwin (BIN)
base->diff (BIN)
base->diffutils (BIN)
base->fileutils (BIN)
base->findutils (BIN)
base->gawk (BIN)
base->gdbm (BIN)
base->grep (BIN)
base->gzip (BIN)
base->libncurses5 (BIN)
base->libncurses6 (BIN)
base->libreadline4 (BIN)
base->libreadline5 (BIN)
base->login (BIN)
base->ncurses (BIN)
base->readline (BIN)
base->sed (BIN)
base->sh-utils (BIN)
base->tar (BIN)
base->termcap (BIN)
base->terminfo (BIN)
base->textutils (BIN)
base->which (BIN)
base->zlib (BIN)

database->postgresql (BIN & SRC)

devel->binutils (BIN)
devel->gcc (BIN)
devel->gdb (BIN)
devel->gettext (BIN)
devel->indent (BIN)
devel->make (BIN)
devel->mingw-runtime (BIN)
devel->swig (BIN)

doc->cygwin-doc (BIN)
doc->man (BIN)
doc->texinfo (BIN) 

interpreters->perl (BIN)

libs->crypt (BIN)
libs->libiconv2 (BIN)
libs->libintl1 (BIN)
libs->libintl2 (BIN)
libs->libpopt0 (BIN)
libs->pcre (BIN)
libs->popt (BIN)
libs->w32api (BIN)

text->groff (BIN)
text->less (BIN)

utils->bzip2 (BIN)
utils->cygutils (BIN)
utils->time (BIN) 

(return to top)

  

--------------------------------------------------------------------------------

Configure PostgreSQL

Once you have completed the Cygwin install, you need to set up PostgreSQL. Start by referring to the Cygwin-PostgreSQL readme file, which should be under /usr/doc/Cygwin/postgresql-xxxx.Readme.

The first thing you will need to do is download and install the latest cygipc from:

http://www.neuro.gatech.edu/users/cwilson/cygutils/cygipc/index.html

Make sure that you get the pre-compiled binary (not the source). Put it in the root of cygwin (C:\cygwin, if you followed the directions).

Here's where you'll start using the Unix interface. Launch cygwin, and type the following lines:

cd /
bunzip2 -c <file name> | tar x

or

cd /
tar xvjf <file name>;

That completes the installation of cygipc.

Next, we will complete the set-up of PostgreSQL. There are two ways that you can run PostgreSQL on NT/2000 - basic and as a service. I think that the main difference between these two is that if you install it as a service, you won't have to re-initialize PostgreSQL each time you re-start your machine.


--------------------------------------------------------------------------------

The following is the basic Cygwin PostgreSQL installation procedure, as describe in the Cygwin/PostgreSQL distribution:

1. Start the cygipc ipc-daemon:

$ ipc-daemon &

2. Initialize PostgreSQL: 

$ initdb -D /usr/share/postgresql/data

3. Start the PostgreSQL postmaster:

$ postmaster -D /usr/share/postgresql/data &

4. Connect to PostgreSQL: 

$ psql template1


--------------------------------------------------------------------------------

The following is the NT services Cygwin PostgreSQL installation procedure:

1. Install the cygipc ipc-daemon as a NT service:

# ipc-daemon --install-as-service

2. Create the "postgres" user account: 

# cmd /c lusrmgr.msc # [3]
# mkpasswd -l -u postgres >>/etc/passwd

3. Grant the "postgres" user the "Log on as a service" user right: 

# cmd /c secpol.msc [4] 

4. Install postmaster as a NT service: 

# cygrunsrv --install postmaster --path /usr/bin/postmaster 
--args "-D /usr/share/postgresql/data -i" 
--dep ipc-daemon --termsig INT --user postgres --shutdown # [5] [6]

5. Create the PostgreSQL data directory: 

# mkdir /usr/share/postgresql/data

6. Change ownership of the PostgreSQL data directory: 

# chown postgres /usr/share/postgresql/data 

** NOTE: You might need to change ownership from the Windows side. Just check... the user "postgres" should be the owner of the directory.

7. Initialize PostgreSQL (*You MUST log in as "postgres" under NT/2000*):

$ initdb -D /usr/share/postgresql/data

** NOTE: You will need to log back in (NT/2000 log in) as someone with admin privileges to do the rest of these. 

5. Start the cygipc ipc-daemon:

# net start ipc-daemon # [7]

6. Start postmaster: 

# net start postmaster # [7]

7. Connect to PostgreSQL: 

# psql -U postgres template1 [8] [9]

The following are the notes to the above: 

[1] The "#" prompt indicates running as a user which is a member of the Local Administrators group.
[2] The "$" prompt indicates running as the "postgres" user. Log in as "postgres" or use ssh to emulate Unix's "su" command.
[3] On Windows 2000, this starts the "Local Users and Groups" applet. On Windows NT 4.0, do the analogous operation. 
[4] On Windows 2000, this starts the "Local Security Settings" applet. On Windows NT 4.0, do the analogous operation. 
[5] Do not use rxvt for this step because the password exchange will not work properly.
[6] Clean postmaster shutdown will only work with a post Cygwin 1.3.2 snapshot from 2001-Jul-28 or later.
[7] Cygwin's bin directory (e.g., C:\Cygwin\bin) must be added to the Windows NT/2000's system PATH and the machine rebooted for the SCM to find cygwin1.dll.
[8] Actually, psql can run under any user account.
[9] One can use PostgreSQL's createuser command or set PGUSER to obviate the need to specify "-U postgres" on the psql command line.

This completes the PostgreSQL setup. Try creating a database. From the Cygwin prompt, type:

createdb -U postgres myGISdb

If this works without an error, your PostgreSQL installation and set-up are complete.

(return to top)

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有