I have an up and running PostgreSQL database. Now I would like to automate some operations on my database but I have a problem with the password.
I am using the following bash script:
#!/bin/bash export PGPASSWORD="postgres" sudo -u postgres psql -d pg_ldap -w --no-password -h localhost -p 5432 -t -c "SELECT id FROM radusers WHERE id=1"
When I run the bash script I get the following error:
psql: fe_sendauth: no password supplied
I have even tried to configure the .pgpass file in my home directory but to no avail:
I have run the following command:
sudo chmod 0600 .pgpass
Nevertheless it does not seem that any of the methods works. Does anyone have any idea? Am I forgetting to do something?