0

I would like to save extra rare Chinese character in database using mysql, however keep showing ???? after the text is inserted into the table. Previously I have searched how to insert any 4byte Chinese character into mysql data, and following the process ("Incorrect string value" when trying to insert UTF-8 into MySQL via JDBC?) but still no use. Is there something I miss?

Fyi, I have updated mysql version into 5.7.18, and I try to insert the extra rare Chinese character from phpmyadmin directly. thanks in advance!

rifleon
  • 105
  • 1
  • 1
  • 10
  • You only mention utf8mb4, without giving the least information about how you are using it. – Álvaro González May 31 '17 at 14:12
  • What kind information do you need? I just want to save 4byte character into my table – rifleon May 31 '17 at 14:14
  • I'm confused. Do you mean that you haven't tried anything? You just installed MySQL and tried with whatever default settings there are? – Álvaro González May 31 '17 at 14:19
  • No, I just upgraded mysql into latest version due to my previous mysql version is less than 5.5. I updated due to suggestion from link above, I have tried to configure the charset and collation variable into utf8mb4, however the retrieved data still showing ???? character. Please advise – rifleon May 31 '17 at 14:27

2 Answers2

1

As per the CREATE TABLE Syntax:

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    (create_definition,...)
    [table_options]
    [partition_options]

[...]

table_option:
    ENGINE [=] engine_name
  | AUTO_INCREMENT [=] value
  | AVG_ROW_LENGTH [=] value
  | [DEFAULT] CHARACTER SET [=] charset_name

In other words:

CREATE TABLE test (
   some_column VARCHAR(100)
)
CHARACTER SET = utf8mb4;

It won't hurt either to pick a specific collation.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • Sorry for the inconvenience, but I have changed the database server, table name, and respective column into collation utf8mb4, but could it be the problem due to my column type is text not varchar the issue? – rifleon May 31 '17 at 14:43
  • A `TEXT` column with `utf8mb4` charset can store the same characters than a `VARCHAR` column with `utf8mb4` charset. – Álvaro González May 31 '17 at 14:48
1

You also must change the connection to be utf8mb4. See http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored for discussion of "question marks".

Note: The data failed to be stored correctly; it cannot be recovered without re-inserting the data.

Rick James
  • 135,179
  • 13
  • 127
  • 222
  • Thanks, I have checked the connection and it seems my font not supported for this extra rare Chinese character. I just found the link for this extra rare Chinese character in here, https://www.download-free-fonts.com/details/90428/simsun-founder-extended – rifleon Jun 04 '17 at 10:33