Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSql "running post install step…the Database Cluster Initialisation failed"

I'm a Windows user - it took me a couple of hours of constant installs and uninstalls before I could get this working, with the first 10 or so times coming to see the error message in the title.

I place this here as a self-answered question to prevent others who might run into the same problem while installing, and include some basic usage methods for those like me who are first comers in using PostgreSql.

like image 522
dk123 Avatar asked May 08 '14 06:05

dk123


People also ask

What is Initdb?

initdb initializes the database cluster's default locale and character set encoding. The character set encoding, collation order ( LC_COLLATE ) and character set classes ( LC_CTYPE , e.g., upper, lower, digit) can be set separately for a database when it is created.


2 Answers

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

like image 107
ALS Avatar answered Sep 29 '22 10:09

ALS


I faced some major issues with this myself when trying to install PostgreSQL 9.6 and couldn't get it working despite the above answers. What solved it for me was either

In the installer

When prompted for locale, do not check 'default locale'. Instead, choose something like 'United States English'. For some reason, the default doesn't work.

After the installer

If you went ahead and checked 'default locale' anyways, you can still fix the installation errors without reinstalling the whole thing. What you need to do is similar to above answers, but with slight changes:

  1. Go to your postgres /bin directory (default location: "C:\Program Files\PostgreSQL\9.6\bin") and execute the following query:

initdb -D "C:\Program Files\PostgreSQL\9.6\data" -U postgres --locale="English_United States.1252"

As you can see, locale is not an intuitive string such as "en_US.UTF8", so this can get quite nasty if you don't know what is going on. Anyways, the above code should result in a "Success" message.

  1. Next, execute the following command:

pg_ctl register -N PostgreSQL -D "C:\Program Files\PostgreSQL\9.6\data"

This should result in a windows service called PostgreSQL.

  1. Lastly, to start your newly created service, enter:

net start PostgreSQL

That's it. everything should be up and running now.

like image 22
Andreas Forslöw Avatar answered Sep 29 '22 09:09

Andreas Forslöw