Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django OperationalError 2019 Can't initialize character set utf8mb4

I have struggled with this all day and have not been able to find a solution or even the root cause of the error. When I run my app locally it works fine. My production instance is using Heroku cedar stack and Amazon RDS MySQL databases.

In my settings file I have: 'OPTIONS': {'charset': 'utf8mb4'}

When I push to Heroku it crashes with the error: _mysql_exceptions.OperationalError: (2019, "Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/)")

The exception location: /app/.heroku/python/lib/python2.7/site-packages/MySQLdb/connections.py in set_character_set, line 298

I have created the appropriate Data Base parameters with Amazon RDS MySQL and are currently set as follows:

+--------------------------+-------------------------------------------+
| Variable_name            | Value                                     |
+--------------------------+-------------------------------------------+
| character_set_client     | utf8mb4                                   |
| character_set_connection | utf8mb4                                   |
| character_set_database   | utf8mb4                                   |
| character_set_filesystem | binary                                    |
| character_set_results    | utf8mb4                                   |
| character_set_server     | utf8mb4                                   |
| character_set_system     | utf8                                      |
| character_sets_dir       | /rdsdbbin/mysql-5.6.13.R1/share/charsets/ |
+--------------------------+-------------------------------------------+

I am running:

MySQL 5.6.13
MySQL-python==1.2.4

Thanks in advance for your help. Let me know if there are more details that I am missing.

like image 489
bevinlorenzo Avatar asked Oct 22 '22 01:10

bevinlorenzo


2 Answers

Turns out the issue falls on Heroku and their lack of support for the needed library:

Here is what the support folks at Heroku told me:

This encoding requires an up-to-date version of MySQL's libmysqlclient C shared library. Sorry but we don't currently have plans to upgrade this library in the immediate future. You can build your own versions of binary dependencies by following the instructions at https://devcenter.heroku.com/articles/buildpack-binaries

like image 159
bevinlorenzo Avatar answered Oct 27 '22 10:10

bevinlorenzo


For future readers: the solution to this specific issue as of late 2014 is to use the cedar-14 stack, which includes up to date mysql binaries (tested by me). A general solution would be to compile your own binaries and create a custom buildpack, as advised by the heroku people.

like image 27
riffraff Avatar answered Oct 27 '22 09:10

riffraff