Home > Database > Mysql Tutorial > MySQL命令行查询中中文乱码问题的解决

MySQL命令行查询中中文乱码问题的解决

WBOY
Release: 2016-06-07 15:40:17
Original
1235 people have browsed it

问题 在使用Mysql命令行进行查询的时候,经常会出现中文乱码的问题 解决方案 在MySQL命令行输入: show variables like ‘character_set_%’; 查看当前配置的编码; 在MySQL命令行输入 : set names utf8; 等同于 set character_set_client=utf8; set character

问题

在使用Mysql命令行进行查询的时候,经常会出现中文乱码的问题


解决方案

在MySQL命令行输入:show variables like ‘character_set_%’;查看当前配置的编码;

在MySQL命令行输入 :set names utf8; 等同于

set character_set_client=utf8;

set character_set_results=utf8;

set character_set_connection=utf8;



在命令行插入数据之前

执行命令set names gbk;或者set names gb2312;

再插入


查询数据之前

执行命令set names gbk;或者set names gb2312;

完了之后再set names utf8;

这样就能正常插入和查询中文并且保持数据库编码为utf8

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