1
votes

When using the dbname parameter with pg_dump.exe, I get the following error:

Error:

pg_dump: [archiver (db)] connection to database "my_database" failed: invalid port number: "mypass@my_server.postgres.database.azure.com:5432/my_database"

Command:

pg_dump.exe --dbname=postgresql://my_user@my_server:mypass@my_server.postgres.database.azure.com:5432/my_database

I assume this is due to the '@' in the username. But without providing the server/host, I get this:

pg_dump: [archiver (db)] connection to database "my_database" failed: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in format. FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in format.

1

1 Answers

3
votes

try connection string (with urlencoded value instead @), eg:

t=# create user "us@r" password 'a@a';
CREATE ROLE
t=# grant CONNECT ON DATABASE t TO "us@r";
GRANT
t=# grant all on a to "us@r";
GRANT
t=# \! pg_dump -d "postgres://us%40r:a%40a@localhost:5432/t" -t a -s | head -n 3
--
-- PostgreSQL database dump
--