mysql utf8 encoding and unique keys
-
26-10-2019 - |
Question
I am inporting data fom a user table (many users from many sites):
myisam default collation latin1_swedish
....
Importing that data into a innodb table utf8_general
I have placed a unique key on the username,site_id
combination but this is failing on 2 users of the same site:
user 1 dranfog,
user 2 drånfog
If I run:
SELECT IF('å' = 'a', 'yep', 'nope');
directly on the target db with utf8 encoding, I get 'yep'
.
Any tips on resolving this most welcome. I was of impression utf8 would treat these as different charcters but that seem to not be the case.
Solution
Collations that end with _ci
are case (and accent) insensitive.
You could change the collation to 'utf8_binary'
to treat dranfog
differently than drånfog
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow