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:
- 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.
- 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.
- Lastly, to start your newly created service, enter:
net start PostgreSQL
That's it. everything should be up and running now.