I have MySQL table with column and its properties:

name:               message
datatype:           varchar(300)
default/expression: utf8

I trying to insert new data in table that contain text in Cyrillic.

Here's my sql query:

INSERT INTO db.log (id, info_id, user_id, timestamp, operation, message) 
  VALUES ('792','575', '35','2016-12-20 12:09:45','add',
  '[email protected] created new line ั‚ะตัั‚ ')

I got the exception:

1 row(s) affected, 1 warning(s): 1366 Incorrect string value: '\xD1\x82\xD0\xB5\xD1\x81...' for column 'message'

What can I do to resolve the exception?

1

There are 1 answers

0
e5d3e1 On BEST ANSWER

Seems that the default character set for your database is likely Latin or other, thou it doesn't store Cyrillic.
Use ALTER DATABASE and ALTER TABLE commands to make sure of correct character set:

ALTER DATABASE your_DB_name CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

See more info on your issue here: How to convert an entire MySQL database characterset and collation to UTF-8?