postgresql - Postgres - How to use psql to create a database with the -c command and password authentication? -
if run following:
psql -h localhost -u admin -c "create database sales owner admin;"
it returns:
psql fatal: database "admin" not exist
i need use password authentication , have setup .pgpass follows:
localhost:*:*:admin:admin
any ideas?
by default, when connect user, database connected db of same name user.
if want connect different db, must specify in psql
command line. since in case you're trying create db, can't connect yet, must connect db (like template1
or postgres
) exists.
e.g.
psql -h localhost -u admin template1 -c "create database sales owner admin;" ^^^^^^^^^
Comments
Post a Comment