Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DatabaseError: (1071, 'Specified key was too long; max key length is 767 bytes')

I have a django project and I would like to run some unit tests. When I try: python manage.py test it throws this error and I couldn't find much information about it in here.

my db settings in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mydb',
        'USER': 'root',
        'PASSWORD': 'password',
        'HOST': 'localhost',           
        'PORT': '3306', 
    }
} 

It looks like something related with InnoDB and MyISAM but I have no idea what is wrong and how to fix it. Thanks!

django version: 1.5.4
mysql version: 5.5

Also, there is no unique=True set in any of the django models.

like image 291
ogzd Avatar asked Dec 15 '22 03:12

ogzd


1 Answers

solution is

ALTER DATABASE `databasename` CHARACTER SET utf8; 

as already exposed here

https://stackoverflow.com/a/43365860/7708836

like image 69
Giuseppe De Marco Avatar answered Dec 17 '22 17:12

Giuseppe De Marco