Reputation: 13395
What is the correct way to run .sql
script using psql
?
When I do like this
psql D:\scripts\script.sql
It requires password. I pass my db password pass
but it shows error
password authentication failed for user PC_ADMIN
(i.e. my windows user). But my db user has the name postgres
.
How to set in command psql D:\scripts\script.sql\
user and password?
Upvotes: 0
Views: 190
Reputation: 172378
Try like this:
psql -U username -d myDataBase -a -f script.sql
Upvotes: 1
Reputation: 3531
you have to send the user flag to the script,
psql D:\scripts\script.sql -U whateveruser
OR
psql D:\scripts\script.sql --username=whateveruser
otherwise it will assume that the user is the current OS account.
Upvotes: 1