Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Possible Duplicate: askubuntu.com/questions/82031/… –  Mitch Jul 7 '12 at 9:16
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
add comment

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;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.