I am trying to create a spatially enabled PostGIS database. I am following the PostGIS documentation, http://postgis.net/docs/manual-1.5/ch02.html#id2648455.

In the short version, i executed,

createdb yourdatabase
createlang plpgsql yourdatabase

But I did not execute the last three commands,

psql -d yourdatabase -f postgis.sql
psql -d yourdatabase -f postgis_comments.sql
psql -d yourdatabase -f spatial_ref_sys.sql

Is my database still spatially enabled? If not, then can you tell me where these .sql files are located so I can execute those last commands, since I am getting the following error,

postgis.sql: No such file or directory

I am using Ubuntu 12.04

  • 2
    to find your postgis.sql file run "locate postgis.sql" from bash (without the quotes).
    – Kelso
    Commented Jul 18, 2012 at 6:41

2 Answers 2


If you have Ubuntu 12.04, then you should have PostgreSQL 9.1, which makes things awesome for PostGIS 2.0, where you can use use the new EXTENSION framework. To spatially enable a database, use the DDL from a SQL window:


See other details for installing PostGIS 2.0 from source for Ubuntu 12.04 here.

If you are using PostGIS 1.5, you will need the enabler scripts on "mydb", run from the shell:

sudo -u postgres createdb mydb
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -d mydb -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis_comments.sql
  • i actually did goto the /usr/share/postgresql/8.4/contrib/ and found the .sql files there
    – Sam007
    Commented Jul 18, 2012 at 16:12
  • 2
    For using geometry functions like ST_Transform and creating geometry columns the user will also need GRANT SELECT ON spatial_ref_sys TO PUBLIC; GRANT ALL ON geometry_columns TO <my desired user>;
    – geekQ
    Commented Apr 2, 2013 at 10:36
  • 1
    You can also run SELECT postgis_full_version(); afterwards to check that a database is spatially-enabled. Commented Nov 20, 2014 at 6:15

While your database is technically spatial at this point, you would only be working with the inbuilt pg geometry types.

In order to complete your installation, you do need to run the scripts as suggested.

You can find them in your /usr/share/postgresql/[version number]/contrib/ postgis sub-directory.

You should see the following:

legacy_minimal.sql    postgis_upgrade_20_minor.sql    spatial_ref_sys.sql
legacy.sql            raster_comments.sql             topology_comments.sql
postgis_comments.sql  rtpostgis_legacy.sql            uninstall_legacy.sql
postgis_restore.pl    rtpostgis.sql                   uninstall_postgis.sql
postgis.sql           rtpostgis_upgrade_20_minor.sql  uninstall_rtpostgis.sql

Your Answer

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

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