Home > Database > Mysql Tutorial > body text

How to solve the problem of Chinese garbled characters in mysql query

藏色散人
Release: 2021-12-29 11:26:41
Original
15354 people have browsed it

Mysql query Chinese garbled solution: 1. Find the my.ini file in the installation directory and open it; 2. Change default-character-set to utf8; 3. Execute "alter table table name default.. ." command; 4. Restart the mysql service.

How to solve the problem of Chinese garbled characters in mysql query

The operating environment of this article: Windows 7 system, mysql version 5.5, Dell G3 computer.

How to solve the problem of Chinese garbled characters in mysql query?

Solution to Chinese garbled characters in mysql query:

Reinstalled the computer I reinstalled mysql in the system, but when I used it, I found that after inserting Chinese data, the queried data was displayed as question marks in Chinese.

No matter whether it is on myeclipse, the mysql command line window, or SQLyog, Chinese cannot be displayed.

Through the information consulted on the Internet, many friends have encountered such problems and solved them. I learned a lot more because of it.

The following method is for reference only, and it has indeed solved the problem of Chinese garbled characters in mysql that I encountered

Reason: It may be that the encoding format was not set during installation
Performance: The inserted Chinese data is displayed as a question mark when queried
Solution

1. Find the my.ini file in the installation directory and open it;
2. Find The default-character-set inside is changed to utf8; in this way, the tables created in the future will default to the encoding format of utf8
3. However, the databases and tables that have been created need to be set separately. Open the mysql command window;
4. Execute the following two commands
, restart mysql Service

After I did the above steps, the inserted Chinese data was displayed normally in sqlyog and myeclipse, but what was displayed in the command window was not understandable to us. Simplified Chinese, but it is no longer a question mark.

Execute the following command in the mysql command window

set character_set_database=utf8;
 set character_set_server=utf8;
 set character_set_client=gb2312;
 set character_set_connection=gb2312;
 set character_set_results=gb2312;
Copy after login

Finally, the data found in the mysql command window is also normal


Attachment: Mysql knowledge
           

Open the cmd command window: net stop mysql  ---Stop the mysql service

net start mysql ---Start the mysql service

Open the MySQL command window:

## A, enter mysql directly at the start window to open


#b. If you are already in the cmd window and do not want to exit, you can enter mysql -uroot -pmysql; (replace root with your own user name and mysql with your own password)

In the mysql command window, you can execute the following commands/statements

a、show variables like '%char%';  ---查看编码设置
b、show create database 数据库名;   ---查看该数据库的编码格式
c、show create table 表名;   ----查看该表的编码格式 
d、show full columns from 表名;   ---可以查看该表格字段的属性
Copy after login

    

   

Recommended study: "mysql video tutorial"

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!