Uninstall PostgreSQL cleanly

The Windows uninstaller of PostgreSQL 9.1 does not remove postgres service account or the server data directory, for which the default value is C:Program FilesPostgreSQL9.1data.

To completely remove all PostgreSQL artefacts, run the uninstaller, open an elevated command prompt, and issue the following commands:

net user /delete postgres
rmdir /s /q "C:Program FilesPostgreSQL"
del %temp%install-postgresql.log
del %temp%uninstall-postgresql.log
del %temp%bitrock_installer*.log

This performs the following cleanup tasks:

  • Remove the postgres service account.
  • Remove Postgres’s program files directory, which implicitly removes the data directory as well.
  • Delete all log files created during the installation and uninstallation processes. The last command uses a glob because the BitRock installer generates a new file every time it is run.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s