MySQL Chinese display question mark, do not recognize the solution of Chinese

Source: Internet
Author: User
Tags mysql view

From the front-end inserted in Chinese, to the background MySQL view is a question mark.

Can not be displayed in Chinese, the initial decision is the problem of coding.

We use

Show variables like ' character_set_% ';


Show variables like ' collation_% ';

This command checks to see if the MySQL encoding format is the following

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/local/mysql-5.7.16-osx10.11-x86_64/share/charsets/|



Show variables like ' collation_% ';


| variable_name | Value |


| collation_connection | Utf8_general_ci |

| Collation_database | Utf8_general_ci |

| Collation_server | Utf8_general_ci |


After 5.5 MySQL Most people's default configuration should be the same as most of the above, except for the following 2

Character_set_database | Latin1

Character_set_server | Latin1

and Collation_database and Collation_server are different.

The two tables shown above are the result of a modification, so how to modify them.

There are no my.cnf and my-medium.cnf files after 5.5.

There is a my-default.cnf file under the Support-files file.

Do the following. (Close the database and disconnect the database service before you do the following)

sudo cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf

sudo vi/etc/my.cnf

After opening my.cnf, add the following two lines of settings under [mysqld] within the file:

init_connect= ' SET NAMES UTF8 ' save exit

Start the database service from the beginning, open the database, view the encoding format, and discover that it has changed

It is important to note that the encoding format of the table created by default is not changed! So, if you want to make a table that is created before you modify the encoding format, it also modifies

Please follow the instructions below

1. Modify the encoding format of the database

Mysql>alter databases < database name > character set UTF8;

2. Modify the data table encoding format

Mysql>alter Table < name > character set UTF8;

3. Modify the field encoding format

Mysql>alter Table < name > Change < Field name > < Field name > < type > Character set utf8;mysql>alter table user Cha Nge username username varchar (character set UTF8 not null;

The modified database and the tables in the library do not make the original data effective, but the newly added data will not take effect.

MySQL Chinese display question mark, do not recognize the solution of Chinese

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.