Win 10 Postgresql 11 数据库集群初始化失败
Win 10 Postgresql 11 database cluster initialisation failed
我从戴尔 (XPS 15) 买了一台新笔记本电脑,Windows 10 Pro。
我总是遇到同样的问题在安装 postgres "Problem running post-install step. Installation may not complete correctly. The Database cluster initialisation failed." .
我尝试了很多过去线程的解决方案:
不将 postgres 安装到程序文件中
创建一个名为 postgres 的用户,可以完全访问 postgress 目录,在此处解释 https://www.youtube.com/watch?v=pS_zWDDDSe0
检查新的 win-updates
关闭 Windows.
的防火墙和杀毒软件
Error running cscript //NoLogo "C:\develop\postgres/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\develop\postgres" "C:\develop\postgres\data" 5432 "DEFAULT" 0: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.
[14:03:49] Delete the temporary scripts directory...
Creating menu shortcuts...
Executing cscript //NoLogo "C:\develop\postgres\installer\server\createshortcuts_clt.vbs" "PostgreSQL 11" "C:\develop\postgres"
Script exit code: 0
编辑错误日志
Executing batch file 'radAD31B.bat'...
The program "postgres" was found by "C:/develop/postgres/bin/initdb.exe" but was not the same version as initdb.
我刚刚为此苦苦挣扎了几个小时,所以我将其发布给所有来到这里的人。
最初,我只能在 pgsql-bugs
邮件列表中找到两个错误报告:
BUG #15856: The program "postgres" was found by "initdb" but was not the same version as initdb.
BUG #15970: Db initialization error - initdb.exe and postgres not same version
具体症状为:
The program "postgres" was found by ".../initdb.exe" but was not the same version as initdb.
虽然版本匹配,但您会得到:
C:\Program Files\PostgreSQL\bin>postgres -V
WARNING: 01000: could not determine encoding for locale
"<some encoding>.utf8": codeset is "CPutf8"
如果这些是您的症状,问题在于您将 region/language 设置设置为使用 UTF-8(测试版设置)。这会导致很多程序出现问题,PostgreSQL 就是其中之一。禁用它并重新安装,你应该没问题。
按照以下步骤避免此错误
- 卸载 PostgreSQL
- 如果你有 postgres 用户就删除
- 右键单击我的电脑/这台电脑然后单击管理转到本地用户和组 然后 Users New User 输入用户名 postgres 和密码(任何你想要的)然后点击创建 按钮。
- 现在右键单击 postgres 用户并单击 属性 单击 成员选项卡然后在此处的 添加 按钮上单击 高级 并为组打开一个新对话框,单击 立即查找 和 select 管理员 单击 确定 按钮。
- 现在打开命令提示符/cmd
- 在这里输入 runas /user:postgres cmd.exe 然后回车
- cd 下载的 Postgresql 文件夹路径 输入
- postgresql-x.x.x-x-windows.exe进入(这里的x反映release,主要和次要版本)。
- 现在重复第 4 步并删除组 Administrators 并添加 Power Users
我查看了可用的解决方案,但 none 对我有用,所以我只是在我的 Windows 10 桌面上创建了一个新用户并在那里进行了安装,它能够成功完成。
刚刚在 postgres 12 上遇到了这个问题,我的解决方法与 Atif 的类似,但使用的是命令行:
卸载 PostgreSQL
删除 postgres 用户,如果它仍然存在:
net user postgres /delete
使用您能记住的密码创建 postgres 用户:
net user /add postgres [密码]
将 postgres 用户添加到管理员组:
net localgroup administrators postgres /add
跳过这个,因为组在 win 10 和默认用户中不再存在
应该有必要的权限 - 将 postgres 用户添加到
高级用户组
运行 命令 window 作为 postgres 用户:(打开新命令
window) :
运行as /user:postgres cmd.exe
将安装文件复制到该用户可访问的位置,然后运行
例如:
C:\Download\postgresql-12.4-1-windows-x64.exe
从管理员组中删除 postgres 用户:
net localgroup administrators postgres /delete
就是这样。
希望这有用
如果您曾经更改过注册表中的命令行代码编码参数
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun
到 chcp 65001、chcp 1251 或任何其他,这可能是问题所在。
将命令行编码注册表值返回到默认值(空)解决了我的问题。
尝试将您的注册表值更改为空:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun
卸载可能不会删除所有注册表项。您可以在任务栏搜索中输入 registry
并打开 Registry Editor
.
导航至:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE
并删除与 postgresql
有关的条目。
使用 EDB 安装程序在 Windows 上安装 PostgreSQL 是为了更快地获得秃头(呃)。您可以 运行 WSL 上的 PostgreSQL(Windows Linux 的子系统)并在 Windows!
上连接到它
以管理员身份打开 Windows Terminal/PowerShell(右键单击 Windows 11 上的开始图标 -> Windows 终端(管理员)。键入:
wsl --install
重新启动计算机。登录后 Ubuntu 将自动安装,WSL2 和 Ubuntu 是 Windows 11 上的标准配置(查看有关如何 select 不同发行版等的文档)按照说明进行操作输入您想要的用户名和密码。
更新Ubuntu:
sudo apt update && sudo apt upgrade
安装 PostgreSQL:
sudo apt install postgresql
给 'postgres' 用户一个密码:
sudo passwd postgres
启动服务并打开psql shell:
sudo service postgresql start && sudo -u postgres psql
请注意,您创建的密码不是 postgres 的数据库密码,因此除非您创建一个新用户,否则您可以在 psql shell:
中给 postgres 一个
ALTER USER postgres PASSWORD 'mypw';
现在您可以安装 pgAdmin 或使用您自己的程序(在 'normal' Windows 中)以确认您可以在 127.0.0.1 上使用端口 5432(可能不同)与用户 postgres 和他的密码。
我从戴尔 (XPS 15) 买了一台新笔记本电脑,Windows 10 Pro。 我总是遇到同样的问题在安装 postgres "Problem running post-install step. Installation may not complete correctly. The Database cluster initialisation failed." .
我尝试了很多过去线程的解决方案: 不将 postgres 安装到程序文件中 创建一个名为 postgres 的用户,可以完全访问 postgress 目录,在此处解释 https://www.youtube.com/watch?v=pS_zWDDDSe0 检查新的 win-updates 关闭 Windows.
的防火墙和杀毒软件Error running cscript //NoLogo "C:\develop\postgres/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\develop\postgres" "C:\develop\postgres\data" 5432 "DEFAULT" 0: Program ended with an error exit code Problem running post-install step. Installation may not complete correctly The database cluster initialisation failed. [14:03:49] Delete the temporary scripts directory... Creating menu shortcuts... Executing cscript //NoLogo "C:\develop\postgres\installer\server\createshortcuts_clt.vbs" "PostgreSQL 11" "C:\develop\postgres" Script exit code: 0
编辑错误日志
Executing batch file 'radAD31B.bat'...
The program "postgres" was found by "C:/develop/postgres/bin/initdb.exe" but was not the same version as initdb.
我刚刚为此苦苦挣扎了几个小时,所以我将其发布给所有来到这里的人。
最初,我只能在 pgsql-bugs
邮件列表中找到两个错误报告:
BUG #15856: The program "postgres" was found by "initdb" but was not the same version as initdb.
BUG #15970: Db initialization error - initdb.exe and postgres not same version
具体症状为:
The program "postgres" was found by ".../initdb.exe" but was not the same version as initdb.
虽然版本匹配,但您会得到:
C:\Program Files\PostgreSQL\bin>postgres -V
WARNING: 01000: could not determine encoding for locale
"<some encoding>.utf8": codeset is "CPutf8"
如果这些是您的症状,问题在于您将 region/language 设置设置为使用 UTF-8(测试版设置)。这会导致很多程序出现问题,PostgreSQL 就是其中之一。禁用它并重新安装,你应该没问题。
按照以下步骤避免此错误
- 卸载 PostgreSQL
- 如果你有 postgres 用户就删除
- 右键单击我的电脑/这台电脑然后单击管理转到本地用户和组 然后 Users New User 输入用户名 postgres 和密码(任何你想要的)然后点击创建 按钮。
- 现在右键单击 postgres 用户并单击 属性 单击 成员选项卡然后在此处的 添加 按钮上单击 高级 并为组打开一个新对话框,单击 立即查找 和 select 管理员 单击 确定 按钮。
- 现在打开命令提示符/cmd
- 在这里输入 runas /user:postgres cmd.exe 然后回车
- cd 下载的 Postgresql 文件夹路径 输入
- postgresql-x.x.x-x-windows.exe进入(这里的x反映release,主要和次要版本)。
- 现在重复第 4 步并删除组 Administrators 并添加 Power Users
我查看了可用的解决方案,但 none 对我有用,所以我只是在我的 Windows 10 桌面上创建了一个新用户并在那里进行了安装,它能够成功完成。
刚刚在 postgres 12 上遇到了这个问题,我的解决方法与 Atif 的类似,但使用的是命令行:
卸载 PostgreSQL
删除 postgres 用户,如果它仍然存在:
net user postgres /delete
使用您能记住的密码创建 postgres 用户:
net user /add postgres [密码]
将 postgres 用户添加到管理员组:
net localgroup administrators postgres /add
跳过这个,因为组在 win 10 和默认用户中不再存在 应该有必要的权限 - 将 postgres 用户添加到 高级用户组
运行 命令 window 作为 postgres 用户:(打开新命令 window) :
运行as /user:postgres cmd.exe
将安装文件复制到该用户可访问的位置,然后运行 例如:
C:\Download\postgresql-12.4-1-windows-x64.exe
从管理员组中删除 postgres 用户:
net localgroup administrators postgres /delete
就是这样。 希望这有用
如果您曾经更改过注册表中的命令行代码编码参数
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun
到 chcp 65001、chcp 1251 或任何其他,这可能是问题所在。
将命令行编码注册表值返回到默认值(空)解决了我的问题。
尝试将您的注册表值更改为空:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun
卸载可能不会删除所有注册表项。您可以在任务栏搜索中输入 registry
并打开 Registry Editor
.
导航至:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE
并删除与 postgresql
有关的条目。
使用 EDB 安装程序在 Windows 上安装 PostgreSQL 是为了更快地获得秃头(呃)。您可以 运行 WSL 上的 PostgreSQL(Windows Linux 的子系统)并在 Windows!
上连接到它以管理员身份打开 Windows Terminal/PowerShell(右键单击 Windows 11 上的开始图标 -> Windows 终端(管理员)。键入:
wsl --install
重新启动计算机。登录后 Ubuntu 将自动安装,WSL2 和 Ubuntu 是 Windows 11 上的标准配置(查看有关如何 select 不同发行版等的文档)按照说明进行操作输入您想要的用户名和密码。
更新Ubuntu:
sudo apt update && sudo apt upgrade
安装 PostgreSQL:
sudo apt install postgresql
给 'postgres' 用户一个密码:
sudo passwd postgres
启动服务并打开psql shell:
sudo service postgresql start && sudo -u postgres psql
请注意,您创建的密码不是 postgres 的数据库密码,因此除非您创建一个新用户,否则您可以在 psql shell:
中给 postgres 一个ALTER USER postgres PASSWORD 'mypw';
现在您可以安装 pgAdmin 或使用您自己的程序(在 'normal' Windows 中)以确认您可以在 127.0.0.1 上使用端口 5432(可能不同)与用户 postgres 和他的密码。