Postgresql 无法正确安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13875244/
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
Postgresql failed to install correcty
提问by user1903442
I have been trying to install PostgreSQL 9.2 for the last couple of days. I guess I tried everything that I could find online but the service still will not start. I am currently running Windows 7 SP1. I used to have PostgreSQL 8.3 installed and working fine but a couple of weeks ago I decided to uninstall it. I thoroughly uninstalled it (delete the postgres user and the data file) and now every time I try to install any version I get this non-fatal error at the end of the setup when the loading of the database modules takes place. I managed to see that the postgresql service does not start or as windows puts it starts then stops. This is the relevant part of the log file of the installation:
最近几天我一直在尝试安装 PostgreSQL 9.2。我想我尝试了所有可以在网上找到的方法,但该服务仍然无法启动。我目前运行的是 Windows 7 SP1。我曾经安装过 PostgreSQL 8.3 并且运行良好,但几周前我决定卸载它。我彻底卸载了它(删除 postgres 用户和数据文件),现在每次我尝试安装任何版本时,当加载数据库模块时,我都会在安装结束时遇到这个非致命错误。我设法看到 postgresql 服务没有启动,或者如 windows 所说,它启动然后停止。这是安装日志文件的相关部分:
Successfully processed 771 files; Failed processing 0 files
成功处理771个文件;处理 0 个文件失败
initcluster.vbs ran to completion
initcluster.vbs 运行完成
Script stderr:
脚本标准错误:
Configuring database server startup... Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL.2\installer\server\startupcfg.vbs" 9.2 "NT AUTHORITY\NetworkService" "****" "C:\Program Files (x86)\PostgreSQL.2" "C:\Program Files (x86)\PostgreSQL.2\data" "postgresql-9.2" Script exit code: 0 Script output: startupcfg.vbs ran to completion Script stderr: Creating menu shortcuts... Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL.2\installer\server\createshortcuts.vbs" 9.2 "postgres" 5432 "PostgreSQL 9.2 (x86)" "C:\Program Files (x86)\PostgreSQL.2" "C:\Program Files (x86)\PostgreSQL.2\data" "postgresql-9.2" Script exit code: 0 Script output: Start FixupFile(C:\Program Files (x86)\PostgreSQL.2\scripts\serverctl.vbs)... Opening file for reading... Closing file (reading)... Replacing placeholders... Opening file for writing... Closing file... End FixupFile()... Start FixupFile(C:\Program Files (x86)\PostgreSQL.2\scripts\runpsql.bat)... Opening file for reading... Closing file (reading)... Replacing placeholders... Opening file for writing... Closing file... End FixupFile()... createshortcuts.vbs ran to completion Script stderr: Starting the database server... Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL.2\installer\server\startserver.vbs" postgresql-9.2 Script exit code: 0 Script output: Starting postgresql-9.2 Service postgresql-9.2 started successfully startserver.vbs ran to completion Script stderr: Loading additional SQL modules... Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL.2\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files (x86)\PostgreSQL.2" "C:\Program Files (x86)\PostgreSQL.2\data" 5432 Script exit code: 2 Script output: Installing the adminpack module in the postgres database... Executing 'C:\Users\George\AppData\Local\Temp\radA5996.bat'... psql: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. Failed to install the 'adminpack' module in the 'postgres' database loadmodules.vbs ran to completion Script stderr: Program ended with an error exit code Error running cscript //NoLogo "C:\Program Files (x86)\PostgreSQL.2\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files (x86)\PostgreSQL.2" "C:\Program Files (x86)\PostgreSQL.2\data" 5432 : Program ended with an error exit code [10:34:28] Write the data directory to the ini file... [10:34:28] Write the port number, service ID, locale and superuser to the ini file... [10:34:28] Write ServiceID(postgresql-9.2) to registry/ini... [10:34:28] Write Superuser to ini file and windows registry... [10:34:28] Write Service Account to ini file and windows registry... [10:34:28] Write the server description to the ini file... [10:34:28] Write the server branding to the ini file... [10:34:28] Write the 'whether stack-builder is disabled or not' to the ini file... [10:34:29] Finished running post-installation/upgrade tasks. Creating Uninstaller Creating uninstaller 25% Creating uninstaller 50% Creating uninstaller 75% Creating uninstaller 100% Installation completed
回答by Beathoven
I had the same problem. At one point it needs to get a package via internet connection. This is not right because the install package s/b able to install without a connection but that's how it is. Your firewall is blocking the install. Here's what you need to do:
我有同样的问题。有一次,它需要通过互联网连接获取包裹。这是不对的,因为安装包 s/b 能够在没有连接的情况下安装,但事实就是如此。您的防火墙阻止了安装。您需要执行以下操作:
Shut Down Windows Firewall (Control Panel\All Control Panel Items\Windows Firewall\Customize Settings)
关闭 Windows 防火墙(控制面板\所有控制面板项目\Windows 防火墙\自定义设置)
If you use this great program shut down Firewall Control (Exit from task bar or Use Task Mgr to kill UI & Service - 2 items)
如果你使用这个伟大的程序关闭防火墙控制(从任务栏退出或使用任务管理器杀死 UI 和服务 - 2 项)
For downloading Selected Packages: Shut Down Key Protection Services: Shut Down Base Filtering (Leaves you unprotected! - Dependencies will.restart when BFE is restarted) Base Filtering Engine IKE and AuthIP IPsec Keying Modules IPsec Policy Agent ICS ...
下载选定的软件包:关闭密钥保护服务:关闭基本过滤(让您不受保护!-当 BFE 重新启动时,依赖关系将重新启动)基本过滤引擎 IKE 和 AuthIP IPsec 密钥模块 IPsec 策略代理 ICS ...
Don't forget to restart all protections.
不要忘记重新启动所有保护。
回答by ritz14
I faced similar issues of Pg 9.2.4 installer on Win7 x64. It turned out that 'adminpack' module did not load due to stopped postgres service. It starts and then terminates almost immediately. You may check this running Pg service manually to see if it can load. If it cant this may be from missing config files from "data" directory. initdb command cant create valid cluster and copy corresponding *.conf files. I tried to dig into details and the installer has complicated checks of user permissions which could fail in your (and my) case.
我在 Win7 x64 上遇到了 Pg 9.2.4 安装程序的类似问题。事实证明,由于 postgres 服务停止,'adminpack' 模块没有加载。它几乎立即开始然后终止。您可以手动检查这个正在运行的 Pg 服务,看看它是否可以加载。如果不能,这可能是由于“数据”目录中缺少配置文件。initdb 命令无法创建有效的集群并复制相应的 *.conf 文件。我试图深入研究细节,安装程序对用户权限进行了复杂的检查,这在您(和我)的情况下可能会失败。
Just try installing Pg from zip binaries. It took only the following commands (less than 20 minutes). Original article.
只需尝试从 zip 二进制文件安装 Pg。只用了以下命令(不到 20 分钟)。原创文章。
1) Create "postgres" windows user (with no admin rights) and granted it full privileges on your Pg folder and "data" folder. To do this from command line run "cmd" as administrator (press Ctrl-Shift-Enter instead of Enter to run "cmd") and issue: "net user postgres /add". Then right click on your Pg folder (and "data" folder if it is outside) and grant all permissions to "postgres".
1)创建“postgres”windows用户(没有管理员权限)并授予它对你的Pg文件夹和“data”文件夹的完全权限。要从命令行以管理员身份运行“cmd”(按 Ctrl-Shift-Enter 而不是 Enter 运行“cmd”)并发出:“net user postgres /add”。然后右键单击您的 Pg 文件夹(如果它在外部,则为“data”文件夹)并授予“postgres”所有权限。
2) Install Microsoft Visual C++ 20xx Redistributable Package which comes with one click Pg installer (vcredist_x64.exe from Users\"your user"\AppData\Local\Temp\postgresql_installer_****- folder created by one click Pg installer on first run).
2) 安装 Microsoft Visual C++ 20xx Redistributable Package,随附一键 Pg 安装程序(来自 Users\"your user"\AppData\Local\Temp\postgresql_installer_ ****- 第一次运行时通过单击 Pg 安装程序创建的文件夹vcredist_x64.exe )。
3) Unzip Pg binaries to your Pg folder and "cmd" as administrator to its bin directory.
3) 将 Pg 二进制文件解压缩到您的 Pg 文件夹,然后以管理员身份将“cmd”解压缩到其 bin 目录。
4) Run to init cluster: initdb -U postgres -A password -E utf8 -W -D "path to your Pg folder"\data
4) 运行到初始化集群:initdb -U postgres -A password -E utf8 -W -D "path to your Pg folder"\data
5) Run to install windows service: pg_ctl register -N "postgresql" -U ".\postgres" -D "path to your Pg folder/data" -w
5)运行安装windows服务:pg_ctl register -N "postgresql" -U ".\postgres" -D "path to your Pg folder/data" -w
6) Open windows services list and open "postgresql" service properties. Then set password for windows user postgres there. Try starting your new Pg service. If it starts then everything should be ok.
6) 打开 windows 服务列表并打开“postgresql”服务属性。然后在那里为 windows 用户 postgres 设置密码。尝试启动新的 Pg 服务。如果它开始,那么一切都应该没问题。
7) Open bin\pgAdmin3, connect to local server and open postgres database and its metadata. You should see a complaint about missing admin services and a propose to correct this. Just press Ok - 'adminpack' should be installed.
7) 打开 bin\pgAdmin3,连接到本地服务器并打开 postgres 数据库及其元数据。您应该会看到有关缺少管理服务的投诉以及纠正此问题的建议。只需按 Ok - 应该安装“adminpack”。
回答by Anton Sirotinkin
Install postgres only from windows account written in english. For example installation from user "Аня" always fail.
仅从用英文编写的 Windows 帐户安装 postgres。例如,从用户“Аня”安装总是失败。
回答by franck102
Try installing outside of "C:\Program Files" which has special permissions on Windows. We had similar issues and simply by installing into C:\Postres92 everything works right out of the box.
尝试在 Windows 上具有特殊权限的“C:\Program Files”之外安装。我们遇到了类似的问题,只需将其安装到 C:\Postres92 中,一切都可以开箱即用。
回答by JB. With Monica.
I had the same problem, caused by restricted access rights in the Program Filesdirectory, due to the fact that the data directory was C:\Program Files (x86)\PostgreSQL\9.2\data
我遇到了同样的问题,由于Program Files目录中的访问权限受限,因为数据目录是C:\Program Files (x86)\PostgreSQL\9.2\data
Changing the data directory to C:\ProgramData\PostgreSQL\9.2\data
resolved the problem.
更改数据目录以C:\ProgramData\PostgreSQL\9.2\data
解决问题。
回答by Stijn Leenknegt
Solution is to shutdown the windows firewall before installing. After the installation you can enable the windows firewall.
解决方法是在安装前关闭windows防火墙。安装后您可以启用windows防火墙。