Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't migrate django databases on MySQL after upgrading to ubuntu 16.04

Reinstalled system on ubuntu 16.04 and when first trying to run python manage.py makemigrations got the following error:

django.db.utils.OperationalError: (1193, "Unknown system variable 'storage_engine'")

My django databases settings are:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'license_portal',
        'USER': '****',
        'PASSWORD': '****',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS': {
            "init_command": "SET storage_engine=MyISAM",
        },
    },
}

Libraries:

(mmslic) ➜  mmsLicenseServer git:(master) ✗ pip freeze              
Django==1.8.12
django-admin-bootstrapped==2.5.7
django-bootstrap3==7.0.1
MySQL-python==1.2.5
mysqlclient==1.3.7
requests==2.9.1
(mmslic) ➜  mmsLicenseServer git:(master) ✗ dpkg -l | grep -i mysql            
ii  libmysqlclient-dev                            5.7.12-0ubuntu1                                     amd64        MySQL database development files
ii  libmysqlclient20:amd64                        5.7.12-0ubuntu1                                     amd64        MySQL database client library
ii  libmysqlclient20:i386                         5.7.12-0ubuntu1                                     i386         MySQL database client library
ii  libqt4-sql-mysql:i386                         4:4.8.7+dfsg-5ubuntu2                               i386         Qt 4 MySQL database driver
ii  mysql-client-5.7                              5.7.12-0ubuntu1                                     amd64        MySQL database client binaries
ii  mysql-client-core-5.7                         5.7.12-0ubuntu1                                     amd64        MySQL database core client binaries
ii  mysql-common                                  5.7.12-0ubuntu1                                     all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server                                  5.7.12-0ubuntu1                                     all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.7                              5.7.12-0ubuntu1                                     amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.7                         5.7.12-0ubuntu1  
like image 516
charles.fg Avatar asked May 12 '16 00:05

charles.fg


1 Answers

After struggling with this issue I've found that the problem was a change on MySQL 5.7 version.

With MySQL 5.7 the command SET storage_engine=MyISAM won't work, so that was the problem!

As spotted on the MySQL 5.7 documentation use default_storage_engine instead! My configuration became:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'license_portal',
        'USER': '****',
        'PASSWORD': '****',
        'HOST': '127.0.0.1',
        'PORT': '3306',
        'OPTIONS': {
            "init_command": "SET default_storage_engine=MyISAM",
        },
    },
}
like image 90
charles.fg Avatar answered Oct 20 '22 01:10

charles.fg