Bash Script Can't Connect to Azure Postgres using ENV Vars - "The Username should be in <username@hostname> format"
0
votes
0
answers
1090
views
I have a bash script that exports ENV vars to use in connecting to an Azure Postgres DB (
mydb.postgres.database.azure.com
). For the user portion of that specifically it looks like this:
export PGUSER="postgres@mydb"
This works fine to connect to my local DB where the @mydb
part isn't required, but it fails when connecting to Azure (where it is required) with:
> psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in format.
I've found lots of solutions/answers to this like this one and this one however those aren't viable solutions when using ENV vars to set connection details (and while I didn't expect it to work I nonetheless tried changing my script to export PGUSER="postgres%40mydb"
and indeed it did yield the same error).
Does anyone know how to accomplish this?
Asked by Madbreaks
(137 rep)
Sep 28, 2020, 03:39 PM
Last activity: Sep 28, 2020, 08:05 PM
Last activity: Sep 28, 2020, 08:05 PM