pythonmysqlmysql-connector-pythonpython-sql

Character set 'utf8' unsupported in python mysql connector


I'm trying to connect my database to a python project using the MySQL connector.

However, when using the code below,

import mysql.connector

mydb =  mysql.connector.MySQLConnection(
  host="localhost",
  user="veensew",
  password="%T5687j5IiYe"
)

print(mydb)

I encounter the following error:

mysql.connector.errors.ProgrammingError: Character set 'utf8' unsupported

I tried to find out why this is happening and I'm getting the same error always.

MySQL Connector version - 8.0.30

I'd appreciate any help. Thank you in advanced!


Solution

  • I ran into the same issue. There were apparently some changes in version 8.0.30 to the way utf8_ collations are handled (see MySQL Connector release notes). I installed version 8.0.29 which fixed the issue for me.

    pip3 install mysql-connector-python==8.0.29