How to perform common PostgreSQL tasks on Windows

This is mostly a how-to guide for my future self, since I keep running into these issues. I decided to just compile my notes here for my reference, and maybe yours.

Stopping, Starting, or Restarting PostgreSQL Service on Windows

Search for services.msc and open it

You can find out whether PostgreSQL is running or not. You can stop, pause, or restart the service.

Resetting your default PostgreSQL password on Windows

Find your pg_hba.conf, usually in C:\Program Files\PostgreSQL\9.4\data\pg_hba.conf. I accessed mine by opening up pgAdmin III

Find your configuration file. You can see where mine was located:

Edit it to set the "host" line for user "postgres" on host "" to "trust". You can add the line if it isn't there; just insert:

host all postgres trust

before any other lines.

Or use the editor that pgAdmin III provides and double click the entry:

Next, restart PostgreSQL as explained at the top of this article, or try the following:

Then connect using psql or pgAdminIII.

ALTER USER postgres PASSWORD 'newpassword'

Go back to pg_hba.conf and remove the line you added. Then restart the PostgreSQL service as outlined above. Your password should be reset to whatever you changed it to in the ALTER statement.

Other options

Some other internet guides said you can reset your user by typing opening a command prompt and entering:

net user postgres *

(Note that this command must be run in a command prompt with Administrative rights). Shift-right-click on "Command Prompt" in the Start menu and choose "Run as administrator" from the context menu.

You will be prompted to enter and confirm a new password for the user. If you do this, you must then also update the password in the service configuration for any Postgres or related services (such as pgAgent or pgBouncer) that may use the account, or expect them to fail to start at the next reboot.

The above didn't work for me, as I ended up with a

C:\Windows\system32>net user postgres *
The user name could not be found.

If all else fails...

I had a serious foobar situation and just ended up uninstalling and reinstalling PostgreSQL. Here's a link to the download page. Just for safety I deleted everything in C:\Program Files\PostgreSQL\9.4\data since I didn't care about my previous data.