You don't want to do that because any user on the system can see the command, and thus the password. You want to use a .pgpass file instead:Hi:
Is there a way to require and specify a password at the cmd line for a connect?
-- Greg Smith 2ndQuadrant Baltimore, MD PostgreSQL Training, Services and Support gr...@2ndQuadrant.com www.2ndQuadrant.com
Hi there,
There are no options such as these....what you do instead is use a
pgpass file:
http://www.postgresql.org/docs/8.4/static/libpq-pgpass.html
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
r...@iol.ie
--
Sent via pgsql-general mailing list (pgsql-...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
[snip]
> There are no options such as these....what you do instead is use a
Actually, to correct myself, there *are* these options - but the
--password option just forces a password prompt - it doesn't actually
allow you to specify the password.
Have a look at psql --help for all the options.
PGPASSWORD=fee psql --username foo ...
><html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
> hemas-microsoft-com:office:word" xmlns=3D"http://www.w3.org/TR/REC-html40">
for winders
set PGPASSWORD=fee
psql --username foo ....
as long as it's not in the default environment it's better than a
command-line password.
> as long as it's not in the default environment it's better than a
> command-line password.
On some platforms it's possible to see all of a process's environment
variables using ps-like tools. That's why PGPASSWORD is deprecated.
If you're certain that your platform is not like this, then
"export PGPASSWORD=foo" is probably reasonably safe. On the whole,
though, a .pgpass file is probably safer as well as more convenient.
regards, tom lane