8

I can't install Postgresql. I've tried everything:

  • I run the setup as Administrator.
  • I create a postgresql user an I add it to the Administrator group.
  • I install it directly on C:\postgresql.

but without any success. for information: I have windows 8

miken32
  • 42,008
  • 16
  • 111
  • 154
xAminex
  • 393
  • 2
  • 6
  • 18
  • 1
    What is the exact error message? Also you don't need a separate Windows user for any recent Postgres version. There also should be an installation log. Is there anything in there? –  Sep 08 '15 at 09:27
  • The error message that I recieve is this one : http://i.stack.imgur.com/LHAxi.png – xAminex Sep 08 '15 at 09:46

17 Answers17

8

it's 2019, and I still have the same issue with Postgres 11. Before that, I remove the current Postgres 9.6 (if I remember the version correctly), and attempt to install the new one Postgres 11, and got the issue. I have try these following approaches, but none of them work:

  • Run installation as Administrator on every run -> failed
  • Choose the default installation folder that the setup prompted (C:/Program Files/PostgresSQL/11), and the data folder reside at other place -> failed
  • Install it on a place outside C:/ -> still failed

The only approach that I luckily found after scratching my head nearly the whole day is with this post
I would like to quickly recap the solution in case the the link expired

Solution:
- Uninstall PostgreSQL
- CMD: net user postgres /delete
- Control Panel -> User Accounts -> Configure advanced user profile properties -> delete all "Unknown User" instances that seem to be left from postgres
- Run > compmgmt.msc -> Local Users and Groups -> Users -> New User... -> User name: postgres, Password: postgres -> Create
- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Add... -> Administrators -> OK
- copy postgresql-8.4.9-1-windows.exe to C:\
- runas /user:postgres cmd.exe -> cd \ -> postgresql-8.4.9-1-windows.exe -> installed successfully without errors. Checked data folder and confirmed files created successfully. (this mean you must run the installation with the created postgres user)
- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Administrators -> Remove
- compmgmt.msc -> Local Users and Groups -> Users -> postgres -> Member of -> Add... -> Power Users -> OK
- Installed HM2 -> created db successfully
- Restarted computer -> HM2 runs properly (i.e. just to check postgresql service starts automatically)

Pro Tips: To get an insight of the installation log, go to %TEMP% folder by searching for "%TEMP%" in the task bar, the log name would be bitrock_installer-xxx.log. You would want to know what is going on to troubleshoot the issue faster.

ThangLeQuoc
  • 2,272
  • 2
  • 19
  • 30
7
  • First of all run the set-up as administrator.
  • Choose the installation folder inside program files( default)
  • But chose your data location outside from above folder to somewhere else ( c:\postgres data or something.)
ISONecroMAn
  • 1,460
  • 2
  • 16
  • 23
6

For me it failed every time and for every solution mentioned here. Then after doing a little R&D of my own I was able to successfully use postgresql. Below mentioned are the steps to be followed when you encounter this error "the database cluster initialisation failed"

You have to mannualy run initdb which is present : "C:\Software\PostgreSql\12\bin"

Now make sure u associate "postgres" as user alongwith the initdb cmd since "postgres" is the superuser that got created during installation.

initdb -D "D:\PostgreSql\12\data" -U postgres

Now once database cluster is initialized then you can start the server by using pg_ctl utility present inside bin folder of PostgreSql\12

pg_ctl start -D "D:\PostgreSql\12\data"

Or you can also register it as a windows service and you can set it to automatic

pg_ctl register -N PostgreSql-12.3.1 -D "D:\PostgreSql\12\data"

Now you are all set to use the postgresql database. Either use it through cmd line (psql) or pgAdmin4

ALS
  • 338
  • 3
  • 7
2

Just don't use EDB installer. There is BigSQL alternative now.

Basil
  • 2,650
  • 1
  • 10
  • 4
1

I was installing the Postgres version 9.5 (On windows 7 and using the DBEnterprise installer)... for me, the problem seems to be that I was selecting "POSIX" as Regional Configuration... But I tried with the "C" Regional Configuration, and the installation finished without any problem...

Also, I run the installer as Administrator!

Carlitos Way
  • 3,279
  • 20
  • 30
1

I was facing the same issue on trying to install postgres 10.3.Running as the administrator didn't help me. But it got installed properly when i changed the installation directory from the default one which is inside Program Files.Instead i created a new folder inside the C drive and made it the installation directory.

Shamil Puthukkot
  • 442
  • 2
  • 17
0

Problem solved:

run the setup as Administrador and use Windows 7 mode

xAminex
  • 393
  • 2
  • 6
  • 18
0

Possible solution for 10.3. version:

  1. Download PostgreSQL installation file

  2. Move downloaded file to C:\ drive.
    Example: C:\postgresql-10.3-2-windows-x64.exe

  3. Create directory named PostgreSQL in C:\ drive

  4. Create directory named 10 in previously created PostgreSQL directory.
    So you need to have C:\PostgreSQL\10.

  5. Run C:\postgresql-10.3-2-windows-x64.exe (DO NOT CLICK ON 'RUN AS ADMIN', just double click)

  6. Change installation directory path to C:\PostgreSQL

  7. Change data directory path to C:\PostgreSQL\data

  8. Finish

Hopefully, installation should be successful.

Anis Alibegić
  • 2,941
  • 3
  • 13
  • 28
0

I followed steps suggested by @IsoNecroMad and it worked

1) First of all, run the set-up as administrator.

2) Choose the installation folder inside program files( default)

3) But chose your data location outside from above folder to somewhere else ( c:\postgres data or something.)

0

I tried and failed several times thinking it was somthing to do with rights and user used during the installation. But thanks to ThangLeQuoc's pro tip to inspect the installation log I found the cause:

initdb: invalid locale name "NorwegianBokm†l,Norway"

Called Die(Failed to initialise the database cluster with initdb)...

Failed to initialise the database cluster with initdb

So after selecting 'default locale' during the installation process it all went fine. This was on version 11.6 os Postgres.

Community
  • 1
  • 1
superodde
  • 131
  • 1
  • 3
0

I had the same error, but with different underlying problem (not user permissions but a locale problem). Solution for this is described here: Win 10 Postgresql 11 database cluster initialisation failed

Zbyl
  • 2,130
  • 1
  • 17
  • 26
0

Another way to solve this problem is to change the region (language) of your operating system (Machine). If you choose for example French, take French from France and not local French. Same for English, not local English. Some characters do not work with the local language. I think it will resolve your problem.

Y4glory
  • 1,111
  • 6
  • 17
0

It is 2021 and I had the error message with PostgreSQL 13 (and the official EDB installer): "Problem running post-install step. Installation may not complete correctly. The database cluster initialization failed."

The reason was that I tried to install PostgreSQL on an USB Stick formatted with FAT32 (I just wanted to try it, not use it for important data). While it is possible to store the programs on the USB stick (573 MB), the data directory had to be on the internal disk formatted with NTFS. I tried to use initdb directly (on the USB stick) and there were error messages that it could not create links. This probably explains why the FAT32 format is not possible for the data directory.

StefanB
  • 89
  • 1
  • 3
0

I had the same issue with PostgreSQL 13.4 on Windows and the problem was that the post install script, initcluster.vbs, was being run without the last parameter. I had copied the command from the install-postgresql.log file and tried to run it in a command window and received the following message:

Usage: initcluster.vbs <OSUsername> <SuperUsername> <Password> <PasswordDir> <Install dir> <Data dir> <Port> <Locale> <CheckACL>

I looked at the command I had tried to run and it was missing the <CheckACL> parameter altogether. I retried the command adding true as the last parameter and it ran successfully. After completing the script I ran the following command from the c:\Program Files\PostgreSQL\13\bin folder:

pg_ctl register -N PostgreSql-13.4 -D "<my data directory>"

This registered it as an automatic start service. I went to the Windows Services app and started it. After that I was able to use pgAdmin 4 to connect.

HisDivineShadow
  • 1,036
  • 1
  • 12
  • 21
0

Run PostgreSQL on WSL (Windows Subsystem for Linux) and connect to it on Windows.

Open Windows Terminal/PowerShell as administrator (right click the start-icon on Windows 11 -> Windows Terminal (administrator). Type:

wsl --install

Reboot your computer. After login Ubuntu will automatically be installing, WSL2 and Ubuntu is standard on Windows 11. Follow the instructions to enter your desired username and password.

Update Ubuntu:

sudo apt update && sudo apt upgrade

Install PostgreSQL:

sudo apt install postgresql

Give the 'postgres' user a password:

sudo passwd postgres

Start the service and open psql shell:

sudo service postgresql start && sudo -u postgres psql

Notice that the password you created is not the DB password for postgres, so unless you create a new user you can give postgres one in the psql shell:

ALTER USER postgres PASSWORD 'mypw';

Now you can install pgAdmin or use your own program (in 'normal' Windows) to confirm that you can connect on 127.0.0.1 with port 5432 (may vary) with the user postgres and his password.

0

!!! You needn't to install it in any special place

if you meet this problem, try: 1, not set the data folder besides the root folder,although it is the default 2, check your antivirous software, like 360.

zephms
  • 11
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Emmanuel Meric de Bellefon Feb 27 '22 at 11:45
0

If you are working at a company and they have restrictions on what you can run but you have powershell I found the below to be easier than @ThangLeQuoc answer above and I didn't have any security blockers this way.

From powershell admin window run this.

Note: Password must meet domain password requirements - I used something similar to my own.

New-LocalUser -Name "postgres" -NoPassword
$Password = Read-Host -AsSecureString
$UserAccount | Set-LocalUser -Password $Password
Add-LocalGroupMember -Group "Administrators" -Member "postgres"

Go to https://www.postgresql.org/download/windows/ - click download the installer, download the file and move to C:\ - I used v14 right now From command prompt execute: runas /user:postgres cmd.exe From that window run:

cd \
postgresql-14.7-2-windows-x64.exe

Do the install, put the files in a folder in root like c:\postgre

Remove the user from admin group now:

Remove-LocalGroupMember -Group "Administrators" -Member "postgres"