diff --git a/collectors/0/mysql.py b/collectors/0/mysql.py index 5ef5f755..dbe1d82d 100755 --- a/collectors/0/mysql.py +++ b/collectors/0/mysql.py @@ -120,11 +120,18 @@ def _reconnect(self): self.cursor = self.db.cursor() +def unicode_text(txt): + if not isinstance(txt, str): + return str(txt.encode('utf-8')) # Python2 + return txt # Python3 + + def mysql_connect(conn_props): """Connects to the MySQL server using the specified connection properties.""" return MySQLdb.connect(host=conn_props[0], port=conn_props[1], - user=conn_props[2], passwd=conn_props[3]) + user=unicode_text(conn_props[2]), + passwd=unicode_text(conn_props[3])) def todict(db, row):