- Download and run the Postgres Windows installer http://www.postgresql.org/download/windows/
- Initally the only user will be
postgres. Edit thepg_hba.conffile (probably in C:\Program Files (x86)\PostgreSQL\8.4\data) to addtrustto all themethods - Additionally, add
local all all trustto the top row to allow localhost access. - Use
createuser(in C:\Program Files (x86)\PostgreSQL\8.4\bin) to create a new database (super)user- See: http://www.postgresql.org/docs/8.1/static/app-createuser.html
- Protip: add C:\Program Files (x86)\PostgreSQL\8.4\bin\ to your user's PATH
- Use
createdbto create a new database
Test you can access the new database via PgAdminIII.
- Run
pg_dumpwith appropriate options on production server (something likepg_dump --create --host=HOST --port=PORT --username=USERNAME mydatabase > django_db_backup.sql)--createincludes appropriate CREATE statements to recreate the database from the file.
- Copy file to local machine (using FTP or something like
pscp. For examplepscp acadmin@spider:path/to/file.sql C:\path\to\local\copy.sql) - On local machine use copied file as input to
psqlsimilar to this:psql -U USERNAME --file django_db_backup.sql
As written, the above will require the same pre-created database name and username to exist locally as on the production server.
Best: pip install in a virtualenv
- Create a virtualnev to build your Django environment in http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/
- Switch to the created virtualenv and
pip installthe appropriatepsycopg2for your python version number and 32/64bit level from here: https://github.com/nwcell/psycopg2-windows
Alternative: Download a precompiled Windows installer
- Download and run the appropriate release file from this page: http://www.stickpeople.com/projects/python/win-psycopg/