By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,817 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

starting psql in windows

P: 3
Hi there, I am totally new to database programming, and just have a question about starting psql. I've downloaded the latest version of postgresql in windows (xp), and now I need to start using it, except I have no idea where to begin. The documentation at under "starting psql" doesn't seem to be for windows, so I would really really appreciate it if someone could tell me how to start psql in windows.
Thank you.

Jul 18 '07 #1
Share this Question
Share on Google+
4 Replies

P: 3
I should add that I intend to have the databases on this machine, and run queries (and eventually use jdbc) on the same machine.
What I have now is postgresql showing up in my start menu, with these options: configuration files, command prompt, documentation, pgAdminIII, psql to 'postgres', reload configuration, start service, and stop service.
Jul 18 '07 #2

Expert 100+
P: 534
The very short answer is read this manual

You may also want to add some environment variables
(Control Panel -> System -> Advanced -> Environment Variables)
because -
* by default psql assumes your Postgres username from your Windows username.
* then it attempts to login into the database with the same name, which probably does not exist.

Considering that default database name is postgres, and default username is postgres you are unlikely to login unless you provide some command line parameters, "psql -U postgres", for example
To avoid having to do it every time you can simply add env var. PGUSER and/or PGDATABASE to the environment and forget about command line switches.

Optionally you could write a 3-liner batch file (forgotten art and sounds ugly these days), a simple wrapper aroung psql.
Jul 19 '07 #3

P: 3
Hi again, thank you so much for replying. I will read that part of the documentation tomorrow, but off the top of your head, do you know what those variables (PGUSER, PGDATABASE,..) should be set to? Is it the bin directory for PostgreSQL?
Jul 19 '07 #4

Expert 100+
P: 534
PGUSER defines the username under which you are logging in.
So instead of using your Windows username the login is performed using name postgres, if this is what PGUSER is set to.

PGDATABASE defines the name of the database where you're logging in.
If you are going to use the database named postgres, created when you install the server, you don't have to set this variable, because by default psql will try to login into the database with the same name as your username.
Jul 19 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.