简体   繁体   中英

Getting Database cluster error while installing PostgreSql 12 on Windows 10

When I tried to install PostgreSql 11/12 on my windows machine I was getting the below error :

Error while initializing database cluster

错误截图

Below are the details - Port No - 5432 Installation Location - I have tried installing it in C:/ProgramFiles and also directly in C drive Password - test123 I am running the installer as administrator I have access to Temp directory as well. I have tried moving data folder outside of the main folder. Below are the solutions I have tried -

Below is the error in log file:

Error running cscript //NoLogo "C:\pg/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\u6105742\AppData\Local\Temp/postgresql_installer_2714a75545" "C:\pg" "C:\pg\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.
Executing icacls "C:\Users\u6105742\AppData\Local\Temp/postgresql_installer_e172900ce0" /inheritance:r Script exit code: 0

Could someone please help me in this issue?

On Windows I typically don't use the installer any more as its attempt to set privileges correctly is laudable but seems to create more problems than it solves (especially with computers that a part of a Windows domain seem to suffer from that).

Manually running initdb seems to be more robust, but you will have to fix the permissions on the data directory yourself, eg:

"c:\Program Files\PostgreSQL\12\bin\initdb" -D C:\pg\data

If you want a Windows service, this can be done using pg_ctl:

"c:\Program Files\PostgreSQL\12\bin\pg_ctl" register -N postgresql-12 -D C:\pg\data

The Windows service will run using the Windows "Local System" account which sometimes is seen as dangerous - but isn't as dangerous as described in that SO answer, because Postgres will drop all elevated privileges when it starts the service.

The way I fixed this is the folllowing:

  1. Download the Postgres installer for Windows (EDB site)

  2. Open a Powershell with admin rights and execute the following:

    .\\postgresql-<version>-windows-x64.exe --install_runtimes 0 --unattendedmodeui minimal --mode unattended --superpassword "<set your superuser password here>" --servicename "postgreSQL"

Replace the < version > with the current version you are trying to install and the superuser password of your choice.

It will install everything and create a service called postgreSQL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM