From 592cd373a723779e590e5f0d17438fb46334c1b2 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 15 Nov 2011 07:03:40 -0400 Subject: [PATCH] Updated FAQ adding solution to the mysql non utf-8 collation issue --- docs/faq.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/faq.rst b/docs/faq.rst index 05f9248cae..e017c806b1 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -5,6 +5,28 @@ FAQ Frequently asked questions and solutions + +_mysql_exceptions.OperationalError: (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='") +------------------------------------------------------------------------------------------------------------------------------------------------------ + + * Solution:: + + $ manage.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://www.djangoshmango.com/?p=99 + - http://stackoverflow.com/questions/1073295/django-character-set-with-mysql-weirdness + + + Incorrect string value: ``'\xE2\x80\x95rs6...'`` for column ``'content'`` at row 1 ----------------------------------------------------------------------------------