1

I have messed around with the template1 database, and would like to reset everything as it was.

Hence I have done a sudo apt-get purge postgresql

However the next time I reinstalled it, the databases are still there. Why? Nothing has been reset.

1

2 Answers 2

3

When you create your databases, the datafiles for this databases are created. These are (of course) not being purged by apt purge.

If /etc/postgresql/8.4/main/postgresql.conf (presumably it is not 8.4 - use your version`) still exists, you can find a line like

data_directory = '/var/lib/postgresql/8.4/main' # use data in another directory

There you can find the datafiles for your created databases. If you created your own data directories, I believe you remember where they were.

Does the user postgresql still exist? This is the owner of the database files. Delete this user with searching for all his files (use sth like deluser --remove-all-files, man deluser helps you). If this user does not exist, find all files in your filesystem that don't have an associated user and maybe delete them. (Use find / -nouser -nogroup - and again, read man find:-) )

For more information, consult the wonderful postgresql documentation.

2

You don't need to puge and re-install PostgreSQL for that.

sudo -u postgres psql postgres
drop database template1;
create database template1 template template0;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .