-
-
Save dalekunce/9979082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some good references are: | |
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x | |
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/ | |
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392 | |
#1. Install PostgreSQL postgis and postgres | |
#brew will install postgres and postgis using one formula | |
brew install postgis | |
initdb /usr/local/var/postgres | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
# if you dont have brew on your path yet | |
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile | |
source ~/.bash_profile | |
#2. Create a template to be used on creating GIS-enabled databases | |
createdb postgis_template | |
#[Mac OSX] Import Postgis Data | |
psql -d postgis_template -f /usr/local/Cellar/postgis/2.1.2/share/postgis/postgis.sql | |
psql -d postgis_template -f /usr/local/Cellar/postgis/2.1.2/share/postgis/spatial_ref_sys.sql | |
#Test if works | |
psql -d postgis_template -c "SELECT postgis_full_version();" | |
#3. Set template permissions to gisgroup | |
createuser -R -S -L -D -I gisgroup; | |
psql -d postgis_template | |
ALTER DATABASE postgis_template OWNER TO gisgroup; | |
ALTER TABLE geometry_columns OWNER TO gisgroup; | |
ALTER TABLE spatial_ref_sys OWNER TO gisgroup; | |
CREATE SCHEMA gis_schema AUTHORIZATION gisgroup; | |
\q | |
#4. Adds an app to your application | |
createuser -i -l -S -R -d <app_user> | |
psql -d postgres | |
GRANT gisgroup TO <app_user>; | |
\q | |
#5. Create your app database | |
createdb -T postgis_template -O <app_user> <app_db>; |
Still having problems with the two following errors:
typing "psql" returns
psql: FATAL: database "robertbanick" does not exist
robertbanick being my computername in this instance
and initdb /usr/local/var/postgres returns
/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working off a fresh Yosemite install I get the below error when I get to the "initdb /usr/local/var/postgres" stage. All commands that interact with postgres receive this same error.
After some digging, it appears that Yosemite leaves out 4 essential files from the usr/local/var/postgres directory. These files are:
To resolve this I ran
This resolved the problem
More information here: http://stackoverflow.com/questions/25970132/pg-tblspc-missing-after-installation-of-os-x-yosemite