Postgresql – Using psql with two postgresql installations on Windows 7

postgresqlpsql

I have installed two versions of Postgresql, 8.4 and 9.1. When I try to run psql it only picks up the previous psql version. For example, when I run the following line to connect to the database, ax_data:

C:\Program Files (x86)\PostgreSQL\9.1\bin>psql ax_data
Password:
psql (9.1.2, server 8.4.8)
WARNING: psql version 9.1, server version 8.4.
         Some psql features might not work.
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

ax_data=

It is not finding the more recent psql installation. When using pgAdmin, if I click on psql a small command window pops up, but when I type commands in nothing is happening. I'm not very experienced with Postgresql so I could have made some basic mistake somewhere along the way. Any thoughts on what I could be doing wrong?


EDIT:

I am able to login using:

C:\>C:\"Program Files (x86)"\PostgreSQL\9.1\bin\psql.exe -p 5434 -U postgres
psql (9.1.2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# LS
postgres-#

but none of the commands seem to work. For example, whenever I type anything in after the prompt, there is no response.

Best Answer

If you have both versions installed, you can not run both servers at the same time on the same port. So, you can differentiate between the servers by running them on two different ports or by running one at a time.

To differentiate between the two clients, you can simply refer to the client using the full path name.