免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5558 | 回复: 0

setup PostgreSQL under Windows/Cygwin [复制链接]

论坛徽章:
0
发表于 2003-03-06 01:20 |显示全部楼层

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 &amp;

2. Initialize PostgreSQL:

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

3. Start the PostgreSQL postmaster:

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

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)
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

SACC2019中国系统架构师大会

【数字转型 架构演进】SACC2019中国系统架构师大会
2019年10月31日~11月2日第11届中国系统架构师大会(SACC2019)将在北京隆重召开。四大主线并行的演讲模式,1个主会场、20个技术专场、超千人参与的会议规模,100+来自互联网、金融、制造业、电商等领域的嘉宾阵容,将为广大参会者提供一场最具价值的技术交流盛会。




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

大会官网>>
  

北京盛拓优讯信息技术有限公司. 版权所有 16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122
中国互联网协会会员  联系我们:huangweiwei@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP