(This document has been modified to instruct the setup of not only 64-bit systems, but 32-bit set ups as well.)
This tutorial is for individuals who are interested in setting up a DSN entry in their Data Sources (ODBC) for PostgreSQL. We cover both 32-bit and 64-bit versions of Windows, as each must be configured slightly differently.
- Download and install the latest version of psqlODBC from: http://www.postgresql.org/ftp/odbc/versions/msi/
- Please note: If running a 64-bit version of Windows, you will want to download and install BOTH the psqlodbc_XX_XX_XXXX.zip and psqlodbc_XX_XX_XXXX-x64.zip file. If running the 32-bit version of Windows, simply download and install psqlodbc_XX_XX_XXXX.zip.
- Un-Zip and run the MSI contained within the Zip file(s). (Should be named psqlodbc.msi or psqlodbc_x64.msi)
- If running a 32-bit version of Windows:
- Go to Start -> Administrative Tools -> Data Sources (ODBC) (Or, go to Start -> Run and enter: %WINDIR%\System32\odbcad32.exe)
- If running a 64-bit version of Windows:
- To run the 64-bit version of Data Sources: Go to Start -> Administrative Tools -> Data Sources (ODBC) (Or, go to Start -> Run and enter: %WINDIR%\System32\odbcad32.exe
- To run the 32-bit version of Data Sources: Go to Start -> Run (or Press Windows+R keys) and enter %WINDIR%\SysWOW64\odbcad32.exe
- Please note: You CANNOT have the 32-bit and 64-bit versions of odbcad32.exe running at the same time. If you attempt to run one while the other is already loaded, it will simply focus on the one already running.
- On either the User DSN (DSNs available for only that user) or System DSN (DSNs available to every user) tab, click the Add button.
- Scroll down the list and find the PostgreSQL ODBC Driver. You may select ANSI or UNICODE (For future support I personally prefer UNICODE), and click Finish.
- Data Source refers to the programmable name of the DSN Entry. I’d recommend sticking to lower-case letters and underscores. Ex: psql_server
- Specify the Database, Server, User Name and Password to your PostgreSQL server. Alternately, you may also enter a Description, specify a different Port, and set the SSL Mode.
- Click the Test button to ensure everything has been specified correctly.
- Click the Save button to create the DSN.
Some useful notes:
- If running a 64-bit version of Windows, 32-bit applications will reference ONLY the DSNs specified within the 32-bit version of Data Sources (ODBC). Likewise, 64-bit applications will only reference the DSNs specified within the 64-bit version of Data Sources (ODBC).
- If running the 32-bit version of Windows, the above mentioned problems are not applicable.
- If you are having problems Testing the connection before saving the DSN, ensure permissions are set appropriately on the PostgreSQL server’s side by taking a look at the pg_hba.conf file (Generally located at C:\program files\postgresql\9.1\data\pg_hba.conf). If the configuration file is not present within that directory, the file should be present within whatever directory was set as PostgreSQL’s “data” directory which also contains the data files as well).