===============
Troubleshooting
===============


Databases
=========

MySQL
-----

MySQL error: ``OperationalError: (1267, "Illegal mix of collations (latin1_swedish_ci, IMPLICIT) and (utf8_general_ci, COERCIBLE) for operation '='”)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    $ mayan-edms.py shell
    >>> from django.db import connection
    >>> cursor = connection.cursor()
    >>> cursor.execute('SHOW TABLES')
    >>> results=[]
    >>> for row in cursor.fetchall(): results.append(row)
    >>> for row in results: cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0]))

References:

- http://stackoverflow.com/questions/1073295/django-character-set-with-mysql-weirdness


MySQL error: ``Incorrect string value: `'xE2x80x95rs6…'` for column `'content'` at row 1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When using MySQL and doing OCR on languages other than English

Use utf-8 collation on MySQL server, or at least in table
‘documents_documentpage', ‘content' field

References:

- http://groups.google.com/group/django-users/browse_thread/thread/429447086fca6412
- http://markmail.org/message/bqajx2utvmtriixi


MySQL error: ``Error "django.db.utils.IntegrityError IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`…`.`…`, CONSTRAINT `…_refs_id_b0252274` FOREIGN KEY (`…`) REFERENCES `…` (`…`))')``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Solution:
Convert all MySQL tables to the same type, either all MyISAM or InnoDB


MySQL error: ``ValueError: Found wrong number (0) of constraints for actstream_follow(user_id, content_type_id, object_id)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is caused by a bug in Django 1.11. The issue has been fixed for Django 2.0
version which Mayan EDMS will be migrating to for version 4.0.

Mitigation:
Avoid MySQL versions: 8.0.x. Use MySQL 5.7 or earlier.

References:
- https://code.djangoproject.com/ticket/27946
- https://code.djangoproject.com/ticket/29480
- https://github.com/divio/django-cms/issues/5716



.. include::  ../../../partials/kb_migration.txt

.. note::

    Knowledge Base content

    Troubleshooting:

    - Error message "database connection isn't set to UTC"
    - PostgreSQL error: "OperationalError: FATAL:  sorry, too many clients already"
