1

I added this rows to my-default file, restarted server, recreated schema, table and data in the tables, but my cyrillic data still looks like '????'. Now I have a new user and such config, but utf8 still does not work.

[mysqld]
init-connect=SET NAMES utf8
character-set-server=utf8
character-sets-dir=/usr/share/mysql/charsets
default-character-set=utf8

[mysql]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8

[mysqladmin]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8

[mysqlcheck]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8

[mysqldump]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8

[mysqlimport]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8

[mysqlshow]
character-sets-dir=/usr/share/mysql/charsets default-character-set=utf8
#end
3
  • Please see my answer here. If it helps let me know and I will post an answer. Commented Mar 22, 2015 at 21:45
  • 1
    my-default is just a sample. my.cnf (or my.ini) is the file that is used unless you modify the arguments to mysqld.
    – Rick James
    Commented Mar 22, 2015 at 22:01
  • Rick, thank you!! But it still does not work. I can not believe. Commented Mar 22, 2015 at 22:35

3 Answers 3

1

I replaced my.cnf by the default my.cnf, added

CHARACTER SET utf8 COLLATE utf8_general_ci; 

for the DB and all tables.

Now it is works fine! Thank you very much!

0

This will probably do the trick. You need to perform a small query directly before you do INSERT or UPDATE. In my db-class it looks like this, which is to be adapted to your needs. $charset needs to be "utf8"

$db->query('SET CHARACTER SET "' . $charset . '";');
$result = $db->query($query);

I call the function like this

$result = $ddlab->db->db($sql,'utf8');

Good luck !

1
  • Thank you very much for the answer! But sorry for stupid question: what I need to do from mysql console? Cause you queries looks like not pure mySQL. Commented Mar 22, 2015 at 13:00
0

init-connect=SET NAMES utf8

That command is important. However, when you connect as root (or other SUPER user), that command is skipped.

Also, you need to make sure that the bytes in your client are utf8.

And the display is utf8.

If you are using the mysql commandline tool: The command "chcp" controls the "code page". chcp 65001 provides utf8, but it needs a special charset installed, too. To set the font in the console window: Right-click on the title of the window → Properties → Font → pick Lucida Console "

More discussion.

Edit 2

Go into Workbench (which you used for INSERTing the text?) and do SELECT HEX('Ремонтные'); This should give a clue of the character set in Workbench. utf8 will say D0A0D0B5D0BCD0BED0BDD182D0BDD18BD0B5 (note the Dxyy pattern); cp866 will say 90A5ACAEADE2ADEBA5 (note: high bit on). Aha! And latin1 will say 3F3F3F3F3F3F3F3F3F. Look familiar????? Hint: I am pointing finger at Workbench, or your use of it.

11
  • Let's verify what is in the table. Please do SELECT HEX(column) ... to display some field that is coming out "????". Perhaps the data was mangled as it was stored, rather than as it was read.
    – Rick James
    Commented Mar 23, 2015 at 17:43
  • '3F3F3F3F3F3F3F3F3F203F3F3F3F3F3F' Commented Mar 23, 2015 at 18:21
  • Bad news. "3F" is "?". The INSERTs did not have SET NAMES set correctly (or some other problem). Please edit your Question to lay out the details of the INSERT -- including my.cnf settings, connection, SET NAMES (if used), source of data (need to get a feel for what byte encoding was used), etc.
    – Rick James
    Commented Mar 23, 2015 at 18:25
  • Also, please provide (in the Edit), SHOW CREATE TABLE for the table in question.
    – Rick James
    Commented Mar 23, 2015 at 18:25
  • pastebin.com/rn5wrCxS - config. pastebin.com/msuZ4HsV table, etc. Best wishes to California! You are great man! facebook.com/arthur.kharkivskiy I'll glad you to be my friend (not for SQL questions:-)) Commented Mar 23, 2015 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.