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.
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
Execute the following command in the mysql command windowset character_set_database=utf8;
set character_set_server=utf8;
set character_set_client=gb2312;
set character_set_connection=gb2312;
set character_set_results=gb2312;
Attachment: Mysql knowledge
net start mysql ---Start the mysql service
Open the MySQL command window:
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 表名; ---可以查看该表格字段的属性
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!