Home  >  Article  >  Database  >  How to solve the problem of garbled mysql comments

How to solve the problem of garbled mysql comments

藏色散人
藏色散人Original
2023-02-13 09:44:592940browse

Solution to the problem of garbled mysql comments: 1. Check the character set settings of the database and server through the "show variables like '%colla%';show variables like '%char%';" command; 2. Through "set character_set_client=utf8;" just set the result set to utf8.

How to solve the problem of garbled mysql comments

The operating environment of this tutorial: Windows 10 system, Mysql5.7.14 version, Dell G3 computer.

How to solve the problem of garbled mysql comments?

mysql table comments are garbled

Problem: There are comments in the fields in the table when creating the table. Use show create table table_name; to view the fields in the displayed table. The comments are garbled, as follows

How to solve the problem of garbled mysql comments

Check the reason:

这两条命令查看数据库与服务端的字符集设置

show variables like '%colla%';
show variables like '%char%';

How to solve the problem of garbled mysql comments

As expected, the problem lies in the character set problem, because of the wrong setting Set names gbk is used, resulting in the result not being encoded in utf8;

Set the following statement to solve the problem.

set character_set_results=utf8; 返回结果集设置为utf8;
set character_set_client=utf8;
set collation_connection= utf8_general_ci;

How to solve the problem of garbled mysql comments

Recommended study: " MySQL video tutorial

The above is the detailed content of How to solve the problem of garbled mysql comments. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn