2

The commands

Import MySQLdb
MySQLdb.connect(user="root", passwd="1234", charset="utf8mb4")

Work on Linux. But on Windows it throws the following exception: Operational Error (2019, can't initialize character set utf8mb4 (path: c:\\mysql\\\\share\\charsets\\) ")

That path doesn't even exist on my computer, nor in my code.

I'm using MySQLdb version 1.2.5 and mysql 5.7.18.

Using charset=utf8 is not enough because I need to query something like this \U00023456 (4 bytes unicode code points) .

2 Answers2

0

Your version of MySQL doesn't support utf8mb4.

itsrajon
  • 283
  • 2
  • 15
  • The problem is in the client side and not the server side since MySQLdb is a client side library. Also, 1.2.5 is the newest version of MySQL-python – jackLantern Dec 27 '17 at 12:06
0

There are too many backslashes in c:\\mysql\\\\share\\charsets\\. (Before 'share')

Are you using at least mysql 5.5.3?

You probably need use_unicode=True, also.

What is in OPTIONS?

You mean "4 byte UTF-8".

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • I know the path has too many backslashes. It only appears in the exception, not in my code. That folder doesn't even exist. I'm using mysql 5.7.18. In addition, adding use_unicode=True didn't solve the problem. What OPTIONS are you talking about? Thank you. – jackLantern Jan 01 '18 at 09:38
  • The might be an `OPTIONS` in or near the same place where `use_unicode` goes. – Rick James Jan 01 '18 at 15:59