mycli
mycli copied to clipboard
Password with @ in it fails when using DSN
I use Version: 1.23.2 of mycli.
I have this DSN:
myAlias = mysql://username:passwordWith@and@[email protected]:5555/mydb
(a bunch of stuff is changed there)
But when I go:
mycli myAlias
I receive this error:
(2003, "Can't connect to MySQL server on '}gg$' ([Errno -2] Name or service not known)")
If I encode the uri with %40 for the @ signs I receive this error:
Traceback (most recent call last):
File "/usr/bin/mycli", line 33, in <module>
sys.exit(load_entry_point('mycli==1.23.2', 'console_scripts', 'mycli')())
File "/home/troy/.local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
return self.main(*args, **kwargs)
File "/home/troy/.local/lib/python3.9/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/home/troy/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/troy/.local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/mycli/main.py", line 1191, in cli
user = unquote(uri.username)
File "/usr/lib/python3.9/urllib/parse.py", line 654, in unquote
if '%' not in string:
TypeError: argument of type 'NoneType' is not iterable
Do you know how I can make mycli work with @ in the passwords?
Thanks in advance
Hi!
What happens if you run this command?
python -c 'from urllib.parse import urlparse, unquote; uri = urlparse("mysql://username:passwordWith@and@[email protected]:5555/mydb"); print(uri.username); print(uri.password);'
Here I get
username
passwordWith@and@m
suggesting that @
symbols alone are not the source of your issue.
Thanks for the quick response. When I run:
python -c 'from urllib.parse import urlparse, unquote; uri = urlparse("mysql://username:passwordWith@and@[email protected]:5555/mydb"); print(uri.username); print(uri.password);'
I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named parse
if I run:
python3 -c 'from urllib.parse import urlparse, unquote; uri = urlparse("mysql://username:passwordWith@and@[email protected]:5555/mydb"); print(uri.username); print(uri.password);'
I get the same response you do.
/usr/bin/mycli has this:
#!/usr/bin/python3
Not that that means much. it's a tiny script that looks like it calls something else (apologies, I have very little python experience)
You might want to take a look at the python3 -c
output but using your actual DSN instead of the example we are using.
Our example works for both of us, but maybe your actual DSN does not.
when # in the url will get error python -c 'from urllib.parse import urlparse, unquote; uri = urlparse("mysql://root:pken3I#[email protected]:29119/mydatabasess"); print(uri.username); print(uri.password);' --------> None None
Going out on a limb I'd say that I and @liygzting are missing a library that enables us to properly use special characters in passwords.
same issue , because my password contains '#' symbol
when # in the url will get error python -c 'from urllib.parse import urlparse, unquote; uri = urlparse("mysql://root:pken3I#[email protected]:29119/mydatabasess"); print(uri.username); print(uri.password);' --------> None None
Me too
url encoding #
character into %23
as suggested here https://github.com/dbcli/mycli/issues/585#issuecomment-373989269 worked well for me!