1

I am trying to execute a .sql file using UNIX command line for postgres 9.5. I have tried

psql -s localhost -d postgres < filename.sql

where postgres is the name of my database, as well as

psql postgres username < filename.sql

and also

psql -af filename.sql

and I get the result:

Usage: /Library/PostgreSQL/9.5/scripts/runpsql.sh [wait]

for each of these runs. The scripts did not seem to execute, but got no error messages. I am running on Mac OSX.

user3264659
  • 341
  • 2
  • 7
  • 20
  • What is the result of `type psql`? – Abelisto Aug 09 '16 at 21:58
  • `psql is aliased to '/Library/PostgreSQL/9.5/scripts/runpsql.sh'` – user3264659 Aug 10 '16 at 00:56
  • I can guess that you have some product of EnterpriseDB instead of the "pure" PostgreSQL installed. If so then add the `enterprisedb` tag to the your question to get more relevant answers (sorry, have no any experience with EDB). – Abelisto Aug 10 '16 at 06:11
  • thanks. i did download through```http://www.enterprisedb.com/products-services-training/pgdownload#macosx```, hopefully this gives more information to my problem if there is a problem with downloading this way. – user3264659 Aug 10 '16 at 19:50

1 Answers1

-2

It looks like the issue is with the command you are trying to run, specifically with the -s option. According to the PostgreSQL documentation, the -s option is used to specify the name of the system database to connect to, not the hostname.

Instead, try the following command to execute your SQL file:

psql -d postgres -U username -f filename.sql
  • Could you provide a link to where in the PostgreSQL documentation you found this information? This reads a lot like a ChatGPT response. – John Leuenhagen Feb 28 '23 at 00:03