I cannot get a connection to a MySQL database if my password contains punctuation characters in particular $
or @
. I have tried to escape the characters, by doubling the $$
etc. but no joy.
I have tried the pymysql
library and the _mssql
library.
the code... self.dbConn = _mysql.connect(host=self.dbDetails['site'], port=self.dbDetails['port'], user=self.dbDetails['user'], passwd=self.dbDetails['passwd'], db=self.dbDetails['db'])
where self.dbDetails['passwd'] = "$abcdef".
I have tried '$$abcdef', and re.escape(self.dbDetails['passwd']), and '\\$abcdef' but nothing works until I change the users password to remove the "$". Then it connects just fine. The only error I am getting is a failure to connect. I guess I will have to figure out how to print the actual exception message.
尝试使用MySQLdb程序包,您可以通过该程序包中的标点密码来连接数据库。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.