Failed to connect to pgsql while the password contains char '@'
full password is Hi@3812
use
load database from mysql://root:Hi@3812@localhost/enhscada_dc into postgresql://postgres:Hi@3812@localhost/enhscada_dc
or
load database from mysql://root:Hi%403812@localhost/enhscada_dc into postgresql://postgres:Hi%403812@localhost/enhscada_dc
are all auth failed, when cannot change the password, how can i fix it?
Came looking for the same answer, thought mine was broken because my password contained [].
The answer to my problem was in https://github.com/dimitri/pgloader/issues/1197
--> instead of passing the password as part of the connection string, set $PGPASSWORD.
You have the @ twice, so that doesn't help with MySQL, but MYSQL_PWD should do the trick.
Came looking for the same answer, thought mine was broken because my password contained
[].The answer to my problem was in #1197
--> instead of passing the password as part of the connection string, set $PGPASSWORD.
You have the
@twice, so that doesn't help with MySQL, butMYSQL_PWDshould do the trick.
got it, thanks
I faced the same problem and tried several approaches but got nothing working. Finally, I decided to run a simple command in terminal and that got it working.
What I tried that didn't work
- Export global variable
export PG_PASSWORD="MeandHi:m"and used$PG_PASSWORDin the connection string (failed) - Wrapp the passwords for both mssql and postgres in double-quotes (failed), then I used single-quotes (still failed)
- Use the backslash character to escape colon in both connection strings (failed).
- Use character encoding (URL-encoding) thereby using
%3Ain place of:(failed again).
What I tried that worked
pgloader mssql://<username>:<password>@localhost/<database> pgsql://<username>:<password>@localhost/<database>
@CharaD7 , maybe:
- create a sanitizer:
cat > sanitize.sed << _EOF
#!/usr/bin/env sed
s/:/::/g
s/@/@@/g
_EOF
chmod +x sanitize.sed
- construct your conn. url from parts:
username_sanitized="$( echo "${username}" | sed -f ./sanitize.sed )"
password_sanitized="$( echo "${password}" | sed -f ./sanitize.sed )"
and then construct the conn. string:
conn_pgsql="postgresql://${username_sanitized}:${password_sanitized}@${server}/${db-schema}"
WDYT?
@mvk Looks good but seems like too much work. I will consider doing this when running from a script. Thank you!
@ is a keyword you can try double @@ ,like this from mysql://root:Hi@@3812@localhost/enhscada_dc