I 'm using postgres, I created db, user, password, this is the password:
password = name&text@sob
I'm using the following command to dump database and it works on my other databases I have:
pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:[email protected]:5432/db_name
But it doesn't work when using the DB with the password containing &
and @
:
pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:name&text@[email protected]:5432/db_name
doesn't work because of the &
and @
in the password- So I escaped the &
with \
but it didn't work for @
- any suggestions?
Thanks
Create a . pgpass file in the home directory of the account that pg_dump will run as. Then, set the file's mode to 0600 . Otherwise, it will be ignored.
To make that entry work, do not specify a hostname or port for psql , then it will use a "local" connection through named pipes. Alternatively, you can local with host and then add 127.0. 0.1 as the (client) IP address to "trust".
PostgreSQL database passwords are separate from operating system user passwords. The password for each database user is stored in the pg_authid system catalog. Passwords can be managed with the SQL commands CREATE ROLE and ALTER ROLE, e.g., CREATE ROLE foo WITH LOGIN PASSWORD 'secret' , or the psql command \password .
adding ?password=name%26text%40sob
as uri parameter should do:
pg_dump -Fc --no-acl --no-owner --dbname=postgresql://db_user:[email protected]:5432/db_name?password=name%26text%40sob
as per https://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING
Components of the hierarchical part of the URI can also be given as parameters.
update
as Roko noticed, URL has to be encoded
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With