Escape password containing @ when using the postgres pg_dump command

I use postgres, I created db, user, password, this is password:

password = name&text@sob

I use the following command to dump the database and it works with my other databases that I have:

pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:password@127.0.0.1:5432/db_name

But it does not work when using a database with a password containing &and @:

pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:name&text@sob@127.0.0.1:5432/db_name

does not work due to &and @in the password. So I escaped &with \, but it didn’t work for @- any suggestions?

thank

+4
source share
2 answers

adding ?password=name%26te‌​xt%40sobas uri parameter:

pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:password@127.0.0.1:5432/db_name?password=name%26te‌​xt%40sob

https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING

URI .

, URL

+4

, URL.

--dbname=postgresql://db_user:name%26te‌​xt%40sob@127.0.0.1:5432/db_nam‌​e
+1

Source: https://habr.com/ru/post/1679319/


All Articles