Skip to content

Instantly share code, notes, and snippets.

@mildcore
Created April 19, 2020 11:44
Show Gist options
  • Select an option

  • Save mildcore/b23789049bb675bd56ebe16b4bda4849 to your computer and use it in GitHub Desktop.

Select an option

Save mildcore/b23789049bb675bd56ebe16b4bda4849 to your computer and use it in GitHub Desktop.
Verify that tables have utf8 set. Set connection charset. Check database settings.

https://stackoverflow.com/a/11013986

I would not suggest Richies answer, because you are screwing up the data inside the database. You would not fix your problem but try to "hide" it and not being able to perform essential database operations with the crapped data.

If you encounter this error either the data you are sending is not UTF-8 encoded, or your connection is not UTF-8. First, verify, that the data source (a file, ...) really is UTF-8.

Then, check your database connection, you should do this after connecting:

SET NAMES 'utf8'; SET CHARACTER SET utf8; Next, verify that the tables where the data is stored have the utf8 character set:

SELECT tables.TABLE_NAME, collations.character_set_name FROM information_schema.TABLES AS tables, information_schema.COLLATION_CHARACTER_SET_APPLICABILITY AS collations WHERE tables.table_schema = DATABASE() AND collations.collation_name = tables.table_collation ; Last, check your database settings:

mysql> show variables like '%colla%'; mysql> show variables like '%charac%'; If source, transport and destination are UTF-8, your problem is gone;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment