19

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

  • I ran the setup as Administrator.
  • I created a postgresql user and added it to the Administrator group.
  • I installed it directly in C:\postgresql.

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

3
  • 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? Commented Sep 8, 2015 at 9:27
  • The error message that I recieve is this one : i.sstatic.net/LHAxi.png Commented Sep 8, 2015 at 9:46
  • This question is similar to: PostgreSql "running post install step…the Database Cluster Initialisation failed". If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Apr 17 at 12:53

23 Answers 23

26

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 -E UTF8 --locale=en_US.utf8 -U postgres -D "D:\PostgreSql\12\data"

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 as administrator (you need to restart your PC after that):

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

Sign up to request clarification or add additional context in comments.

2 Comments

This works and solved my problem. I have the feeling that the data directory is the problem.
This solved my problem on postgresql-16.2-1-windows-x64.exe
10
  • Run the set-up as administrator.
  • Choose the installation folder inside "Program Files" (default).
  • Choose your data location outside the installation folder ("C:\postgres data" or something).

Comments

9

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.

Comments

3

I tried everything written here and more on internet. Nothing worked until this one:

Locale selection during the installation was always "default locale" for me and my system was setup on "Türkiye" so that letter "ü" was destroying the process. I selected US, English and it worked perfectly. I hope it helps.

Comments

3

I actually created this account just to share this, because I had been looking for a solution for days and couldn’t find anything that worked.

I was having this issue with PostgreSQL and tried several things without success. After installation, I noticed that the data folder inside the PostgreSQL directory was always empty, which seemed to be causing the problem.

I tried downloading the data folder (where the cluster files are stored) through the Command Prompt, and even created a new user account on Windows, but nothing worked.

What eventually solved it for me was installing pgAdmin 4 separately from the PostgreSQL installer. I went to the specific download page for pgAdmin 4, installed it first, ran it, and then restarted my PC as usual.

After that, I downloaded PostgreSQL using the official installer, but this time I unchecked the option to install pgAdmin 4, since I had already installed it. For some reason, that did the trick. I no longer got the “Problem running post-install step; installation may not complete correctly” error, and the data folder was finally created correctly.

Comments

2

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

Comments

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!

Comments

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.

Comments

1

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.

Comments

0

Problem solved:

run the setup as Administrador and use Windows 7 mode

Comments

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.

Comments

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.)

Comments

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.

Comments

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.

Comments

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.

Comments

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.

Comments

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.

1 Comment

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.
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"

Comments

0

tl;dr - Do not install as admin, just a normal user (may require PGDATA to be set).

As of November 2023 I was encountering the same problem running the EDM installer postgresql-16.1-1-windows-x64.exe. Regardless of creating the postgres user, assigning permissions, etc. nothing worked and always got the cluster initialization failed error.

After messing with it for a few hours I noticed that after a "failed" install if I manually initialize the database using .\initdb.exe -D "C:/PostgreSQL/16/data" I could then start the process using pg_ctl BUT it would not work if I tried that from an admin-elevated console.

So I set PGDATA environment variable to "C:/PostgreSQL/16/data" (not sure if this step is necessary, I did it so I didn't have to use -D in my commands when testing), uninstalled postgres, deleted the contents of "C:/PostgreSQL/16/data" and reinstalled as a normal user (NOT as admin), selecting "C:/PostgreSQL/16/data" as my data folder. It installed with no issues at all.

1 Comment

How to install as normal user? when I run the installer exe I get the admin prompt when I use initdb, i get the following error: The system cannot find the path specified. child process exited with exit code 1 initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "c:/Program Files/PostgreSQL/16/bin/initdb"
0

On my case the problem was with the password I used on the install, it contained a utf-8 character

I tried with a password with uppercase+lowercase+numbers and it worked fine

Comments

0

Just sharing, if someone have the same as me. In my case (Windows 10), it was because i made a custom AutoRun for CMD in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor (regedit). Got to reverted that customization back to normal and it works again.

Comments

0

I encountered the same issue in Postgresql 18 on Windows 11. Solutions from other answers did not help.

In my case the issue got fixed by installing the latest C++ Redistributable.

Comments

-1

⚠️ Note: This comment is not directly related to the installation failure described in this question, but I’m posting here because this thread ranks highly for the error message Database initialization failed, which can also occur in entirely different contexts (e.g., during application startup).

In my case, I encountered:


Failed to run Postgres database startup procedure. Errors:
DatabaseError [0001] Database initialization failed for quartz.
Exception: [NpgsqlException] Exception while reading from stream

After extensive investigation, it turned out the issue was due to stale or hanging connections in idle in transaction state — typically left open during debugging (e.g., force-quitting Visual Studio while a transaction is active). These sessions were holding locks on critical tables and blocking schema setup logic, causing misleading startup failures like the one above.

🔍 To investigate, I used:

SELECT
    a.pid,
    a.usename,
    a.datname,
    c.relname              AS relation,
    l.locktype,
    l.mode,
    l.granted,
    a.state,
    age(now(), a.query_start) AS running_for,
    left(a.query, 80)      AS query_snippet
FROM pg_locks l
LEFT JOIN pg_stat_activity a ON a.pid = l.pid
LEFT JOIN pg_class        c ON c.oid = l.relation
ORDER BY l.granted DESC, a.pid;

To resolve:

  • Terminate stale sessions, we restarted db server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.