Skip to content

Instantly share code, notes, and snippets.

@colemanm
Created December 15, 2010 02:30
Show Gist options
  • Save colemanm/741534 to your computer and use it in GitHub Desktop.
Save colemanm/741534 to your computer and use it in GitHub Desktop.
configuring postgres
# Become postgres
sudo su postgres
createuser -SdR mapuser # -S = not super, -d = can create DBs, -R can't create roles
# Creating the template spatial database.
createdb -E UTF8 template_postgis
# Adding PLPGSQL language support
createlang -d template_postgis plpgsql
# Allows non-superusers the ability to create from this template
psql -q -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
# Loading the PostGIS SQL routines
psql -q -d template_postgis -f /usr/share/postgresql/8.4/contrib/postgis.sql
psql -q -d template_postgis -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
# Enabling users to alter spatial tables.
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
# Create a database from template
createdb osm -T template_postgis
# now switch back to your normal user
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment