如何在 Windows 上手动配置和启动 PostgreSQL?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5881845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:20:51  来源:igfitidea点击:

How to manually configure and start PostgreSQL on windows?

windowspostgresqlconfigurationinstallation

提问by onedevteam.com

I have application that use mysql database, but now i need to port it to postgres... In my current installation i have embedded mySQL binaries, and i manually change my.ini file to change default location of mysql server to apppath, install mySQL service and start it... Is this possible (and how) in PostgreSQL?

我有使用 mysql 数据库的应用程序,但现在我需要将它移植到 postgres ......在我当前的安装中,我已经嵌入了 mySQL 二进制文件,并且我手动更改了 my.ini 文件以将 mysql 服务器的默认位置更改为 apppath,安装 mySQL服务并启动它......这在 PostgreSQL 中是否可能(以及如何)?

Thanks in advance

提前致谢

回答by Nirmal- thInk beYond

use pgsql bundle zip so u know actual path that not requires installation

使用 pgsql bundle zip 所以你知道不需要安装的实际路径

initialize database

初始化数据库

initdb.exe <datafolderpath>

init.db & pg_ctl is under

init.db & pg_ctl 在

pgsql/bin

pgsql/bin

start database

启动数据库

"pg_ctl" -D "<datafolderpath>" -l logfile start

回答by a_horse_with_no_name

In addition to what Nirmal wrote, what I usually do:

除了Nirmal写的,我通常会做的:

  • Download the ZIP distribution from http://www.enterprisedb.com/products/pgbindownload.do
  • Unzip the archive
  • Run initdb specifying the location of the desired data directory (note this should notreside in c:\Program Filesas that is not writeable for a regular user. You should create this e.g. in %APPDATA%
  • After initdb has finished, adjust settings in (the generated) postgresql.conf (e.g. shared memory, listen addres, log settings and such). I do this using search & replace.
  • The start the server using pg_ctlas mentioned by Nirmal (and described in the manual).
  • Make sure you start PostgreSQL using the same (Windows) user that you used when running initdb to avoid problems with file permissions!
  • http://www.enterprisedb.com/products/pgbindownload.do下载 ZIP 发行版
  • 解压存档
  • 在initdb指定所需的数据目录的位置运行(注意这应该存在于c:\Program Files作为不可写一个普通用户,你应该创建这个例如,在%APPDATA%
  • initdb 完成后,调整(生成的)postgresql.conf 中的设置(例如共享内存、监听地址、日志设置等)。我使用搜索和替换来做到这一点。
  • 使用pg_ctlNirmal 提到的(并在手册中描述)启动服务器。
  • 确保使用运行 initdb 时使用的相同 (Windows) 用户启动 PostgreSQL,以避免出现文件权限问题!