MySql command line cyrillic Iinsert result is corrupted

character-setcommand lineMySQL

Have putty connection.
Putty config :
window–>translation–>remote character set–>utf-8
Launch command line MySQL client.
Perform insert with cyrillic like:

CREATE TABLE `category` (
  `catName` varchar(40) NOT NULL DEFAULT '',
  PRIMARY KEY (`catName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into category(catName) values ('абвгдйка');

The result is that corrupted cyrillic symbols inserted into DB.

Best Answer

By default MySQL server is using latin1 character set for each incoming connection. Latin1, as you might know, does not support cyrillic symbols.

The simplest solution is to switch so called 'connection character set' by running SET NAMES 'utf8'; in the beginning of each connection.

For example, this query should work:

SET NAMES 'utf8';

CREATE TABLE `category` (
  `catName` varchar(40) NOT NULL DEFAULT '',
  PRIMARY KEY (`catName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert into category(catName) values ('привет русско-говорящему серверу');

To learn about character sets in MySQL and how to make the above change permament see here.