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!
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
If you are using a MySQL connector to connect a MariaDB server, you have to switch to the correct connector:
$ pip3 install mariadb
import mariadb and mariadb.connect. After this step your code should be as the following:import mariadb
mydb = mariadb.connect(
host="localhost",
user="veensew",
password="%T5687j5IiYe"
)
print(mydb)
And voila :)
/!\ Do not downgrade to an older MySQL connector, some other day you will have more problems...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With