B
B
bychok3002016-10-16 23:06:52
MySQL
bychok300, 2016-10-16 23:06:52

Cyrillic support in MySQL, how to add?

I'm trying to set up sql server, nothing happens.
set in config file

skip-character-set-client-handshake
character-set-server = utf8
init-connect='SET NAMES utf8'
collation-server=utf8_general_ci

input output from MySQL
mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using  EditLine wrapper

Connection id:		7
Current database:	
Current user:		[email protected]
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.7.15-0ubuntu0.16.04.1 (Ubuntu)
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/var/run/mysqld/mysqld.sock
Uptime:			26 min 0 sec

Threads: 5  Questions: 48  Slow queries: 0  Opens: 113  Flush tables: 1  Open tables: 32  Queries per second avg: 0.030
--------------
mysql> show VARIABLES LIKE '%CHAR%'; 
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0,01 sec)
mysql> show VARIABLES LIKE '%Coll%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0,00 sec)

when adding the following value to the table:
mysql> INSERT INTO content (id, html) VALUES ( 2, 'привет');
ERROR 1366 (HY000): Incorrect string value: '\xD0\xBF\xD1\x80\xD0\xB8...' for column 'html' at row 1

google this error, or google anything that would help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2016-10-17
@bychok300

ALTER TABLE `content` CONVERT TO CHARACTER SET = utf8;

And new tables must be created immediately in utf8.

D
Dmitry, 2016-10-17
@slo_nik

Goodnight.
Make sure that there is one encoding everywhere, do not limit yourself to mysql.
Encoding of the server, files, comparison of tables and table fields, database connection, etc. etc.
In what encoding do you get the text itself before writing it to the database?
Everything must be in the same encoding.
If the text, for example, is in an encoding other than utf8, there may be problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question