0

I have already create bash script containing sql script (postgresql), but failed.

owner the file : postgres:postgres with 777 (chmod), but when I execute with "./bash1.sh" error: psql: FATAL: role "postgres" does not exist

the bash script:

#!/bin/sh

THE_DATABASE=epolicy
MY_TABLE=hpx_sms

psql ${THE_DATABASE} <<THE_END
  SELECT * FROM ${MY_TABLE};
THE_END

how to fix this problem? or any reference? thank you.

bob
  • 61
  • 2
  • 7
  • Possible duplicate of [psql: FATAL: role "postgres" does not exist](https://stackoverflow.com/questions/15301826/psql-fatal-role-postgres-does-not-exist) – Poshi Jul 24 '18 at 08:02
  • Are you able to access psql from the command line? You might want to find out the appropriate user to log-in the database. It is not a bash script issue, if you can fix this: `psql epolicy`, you can fix your bash script too. – Jyoti Dhiman Jul 24 '18 at 09:49
  • thanks, problem solved, I execute with postgres user, not root or padmin – bob Jul 24 '18 at 09:59

0 Answers0