Saturday, March 13, 2010

PostgreSQL 'permissions error'

Too many times now I've searched high and low to find the cause of my PostgreSQL 'permissions' error. Certainly it didn't make sense...I had created a superuser and a database with that superuser; PostgreSQL was started;

dropdb dbname
would drop the database and
createdb dbname
would create the database. What was wrong?



In each case I had forgotten something so basic most guides seem to leave it out:

initdb
If you're running Ubuntu and installed PostgreSQL through apt-get, you'll need to initialize your database with the commands below as the user you want to own the data. Generally I make a login with the same name as a database superuser to simplify things.



  • Note the folder must also be owned by the user who will own the data.

  • Note multiple databases can be stored in this datafolder.


/usr/lib/postgresql/8.4/bin/initdb -D /path/to/datafolder

No comments:

Post a Comment