Last active
March 2, 2024 17:26
-
-
Save sspecht/9e7ea1ec4193d6f22914 to your computer and use it in GitHub Desktop.
Portable Postgres / PostGIS Install for Windows
This file contains 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
@ECHO OFF | |
REM The script sets environment variables helpful for PostgreSQL | |
@SET PATH="%~dp0\bin";%PATH% | |
@SET PGDATA=%~dp0\data | |
@SET PGDATABASE=postgres | |
@SET PGUSER=postgres | |
@SET PGPORT=5432 | |
@SET PGLOCALEDIR=%~dp0\share\locale | |
cmd |
This file contains 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
set PGPORT=5432 | |
set PGHOST=localhost | |
set PGUSER=postgres | |
set PGPASSWORD= | |
set THEDB=test_postgis | |
set PGINSTALL=%~dp0 | |
set PGBIN=%PGINSTALL%\bin\ | |
set PGLIB=%PGINSTALL%\lib\ | |
set POSTGISVER=2.1 | |
"%PGBIN%\psql" -c "CREATE DATABASE %THEDB%" | |
"%PGBIN%\psql" -d "%THEDB%" -c "CREATE LANGUAGE plpgsql" | |
"%PGBIN%\psql" -d "%THEDB%" -f "share\contrib\postgis-%POSTGISVER%\postgis.sql" | |
"%PGBIN%\psql" -d "%THEDB%" -f "share\contrib\postgis-%POSTGISVER%\spatial_ref_sys.sql" | |
"%PGBIN%\psql" -d "%THEDB%" -f "share\contrib\postgis-%POSTGISVER%\postgis_comments.sql" | |
REM Add topolgy- and raster-SQLs here, if needed. | |
REM Uncomment the below line if this is a template database | |
REM "%PGBIN%\psql" -d "%THEDB%" -c "UPDATE pg_database SET datistemplate = true WHERE datname = '%THEDB%';GRANT ALL ON geometry_columns TO PUBLIC; GRANT ALL ON spatial_ref_sys TO PUBLIC" | |
pause |
This file contains 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
Eine kurze Dokumentation, wie man Postgres/Postgis unter Windows ohne Installation betreibt: | |
- PG-Binaries (ZIP) herunterladen und entpacken | |
http://www.enterprisedb.com/products-services-training/pgbindownload | |
- Batch-Datei lt. Anhang bzw. lt. | |
http://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html | |
im Haupt-Verzeichnis speichern (das Verzeichnis, in dem /bin zu finden ist). | |
- Beim ERSTEN Start der run.bat muss die gekennzeichnete Zeile ausgeführt, danach aber wieder auskommentiert werden. | |
- Fortan startet | |
run.bat den Server (ein Tastendruck in der Konsole beendet den Server wieder), | |
env.bat startet eine Kommandozeile mit Umgebungsvariablen (evtl editieren), | |
im Verzeichnis /bin befindet sich zudem pgadmin3.exe. | |
- Nun kann Postgis nach Anleitung installiert werden | |
http://postgis.net/docs/postgis_installation.html | |
http://postgis.net/windows_downloads | |
Dafür zuerst die zu Postgres passende ZIP laden, entpacken und in das Postgres-Verzeichnis integrieren | |
http://download.osgeo.org/postgis/windows/ | |
Die unten stehende makepostgisdb.BAT-Datei kann als Hilfestellung genutzt werden. |
This file contains 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
@REM source: http://www.postgresonline.com/journal/archives/172-Starting-PostgreSQL-in-windows-without-install.html | |
@ECHO OFF | |
REM The script starts a PostgreSQL server | |
@SET PATH="%~dp0\bin";%PATH% | |
@SET PGDATA=%~dp0\data | |
@SET PGDATABASE=postgres | |
@SET PGUSER=postgres | |
@SET PGPORT=5432 | |
@SET PGLOCALEDIR=%~dp0\share\locale | |
@REM uncomment the line below on FIRST RUN | |
@REM "%~dp0\bin\initdb" -U postgres -A trust | |
"%~dp0\bin\pg_ctl" -D "%~dp0/data" -l logfile start | |
ECHO "Click enter to stop" | |
pause | |
"%~dp0\bin\pg_ctl" -D "%~dp0/data" stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment