I use Postgres 9.1 on Xubuntu 11.10. I've created a db 'aus' and user 'aus', granted ALL on the db to the user. Now I try to import the data, and it outputs this error:

$ osm2pgsql --create --database aus --username aus --prefix planet australia.osm -S /usr/share/osm2pgsql/default.style
osm2pgsql SVN version 0.70.5

Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_point
NOTICE:  table "planet_point" does not exist, skipping
NOTICE:  table "planet_point_tmp" does not exist, skipping
SELECT AddGeometryColumn('planet_point', 'way', 900913, 'POINT', 2 );
failed: ERROR:  permission denied for relation geometry_columns
CONTEXT:  SQL statement "DELETE FROM geometry_columns WHERE
    f_table_catalog = '' AND f_table_schema = 'public' AND f_table_name = 'planet_point' AND f_geometry_column = 'way'"
PL/pgSQL function "addgeometrycolumn" line 133 at EXECUTE statement
SQL statement "SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5)"
PL/pgSQL function "addgeometrycolumn" line 5 at SQL statement

What's wrong with my database?

edit: the solution:

$ sudo su -l postgres
$ psql -d aus
# grant all on database aus to aus;
# alter database aus owner to aus;
$ osm2pgsql ...
here we go...

2 Answers 2


Maybe the user aus is not the owner of the database:

first become super user:

$ sudo su

change to postgres user:

$ su postgres

access postgres, and change the owner, also grant permissions

$ psql


then maybe you still need to change the owner of the tables one by one, I only put you the example of geometry_columns, but also change the owner of spatial_ref, etc.

connect to aus and change owner:

\c aus
ALTER TABLE geometry_columns OWNER TO aus;
  • Indeed, I have messed up with user privileges. I first granted them, then created spatial_ref, geometry and geography tables. Thanks!
    – culebrón
    Dec 10, 2011 at 11:57

You may need to edit /var/lib/pgsql/data/pg_hba.conf to add something like:

host all all md5

so other machines on your network (128.118.54.*) could log on to the database (and remember to restart postmaster).

I have some notes on setting up PostGis and adding OSM data to it at http://ian01.geog.psu.edu/geoserver_docs/index.html that might contain other helpful hints.

  • I don't need to access it from other machines on my network. The file is in /etc/postgresql/9.1/main/ btw.
    – culebrón
    Dec 9, 2011 at 10:41
  • location depends on your distro - you may need to edit anyway as it uses loopback to access the DB.
    – Ian Turton
    Dec 9, 2011 at 12:02
  • is enabled there
    – culebrón
    Dec 9, 2011 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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