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.
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.
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
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
When prompted for locale, do not check 'default locale'. Instead, choose something like 'United States English'. For some reason, the default doesn't work.
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:
"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.
pg_ctl register -N PostgreSQL -D "C:\Program Files\PostgreSQL\9.6\data"
This should result in a windows service called PostgreSQL.
net start PostgreSQL
That's it. everything should be up and running now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With