Friday
3
Jun 2005

MySQL Collation Problems

(8:55 pm) Tags: [Software, Projects]

In one of my projects, I ran across this error in my server logs:

OperationalError: (1267, “Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation ‘=’”)

Google doesn’t give a whole lot of help on the subject, but this bit seemed to help for my problem: Instead of:

CREATE DATABASE dbname;

Try this:

CREATE DATABASE dbname CHARACTER SET utf8;

Where ‘utf-8′ is actually the encoding listed in the left side of the error message. Your database should already be compiled to support it, or it wouldn’t be spitting this error at you :)

This was in MySQL 4.1.10, using Python 2.4.1 and MySQLdb 1.2.0, for those wondering.

Popularity: 21%

Comments: (1)