1. Reasons
1. Inconsistent character sets: Excel’s default character set is GB2312, while MySQL’s default character set is UTF-8 or GBK , which may cause data to be garbled during transmission.
2. Data type mismatch: VARCHAR and TEXT type fields in MySQL can store different character sets, while cells in Excel only support one character set. If Excel cells contain different character sets, garbled characters may appear.
3. Inconsistent file encoding: When using Excel to open or save files in CSV format, encoding inconsistencies may occur. For example, if ANSI encoding is selected when saving a CSV file, and MySQL uses UTF-8 encoding, the data may be garbled during transmission.
2. Solution
In order to avoid garbled characters caused by inconsistent character sets when connecting to MySQL, you need to set the character set to GB2312 to keep the character set consistent. The following parameters can be added to MySQL Connector/ODBC:
charset=GB2312
2. Data type matching: When creating a MySQL data table, VARCHAR and TEXT type fields can be specified as GB2312 character set. For example:
CREATE TABLE test (
id INT NOT NULL,
name VARCHAR(30) CHARACTER SET GB2312 DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
To keep the file encoding consistent, UTF-8 encoding should be selected when using Excel to save CSV files. For example, you can save the file in Excel by clicking "File" -> "Save As" and selecting the "CSV UTF-8 (Comma Delimited)" format.
In addition, sometimes you can also use the SET NAMES command to set the character set in MySQL. For example:
SET NAMES 'GB2312'.
The above is the detailed content of How to solve garbled characters when interacting with Excel and MySQL. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于折叠表格的相关问题,就是分类汇总的功能,这样查看数据会非常的方便,下面一起来看一下,希望对大家有帮助。

在之前的文章《实用Excel技巧分享:利用 数据透视表 来汇总业绩》中,我们学习了下Excel数据透视表,了解了利用数据透视表来汇总业绩的方法。而今天我们来聊聊怎么计算时间差(年数差、月数差、周数差),希望对大家有所帮助!

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于AGGREGATE函数的相关内容,该函数用法与SUBTOTAL函数类似,但在功能上比SUBTOTAL函数更加强大,下面一起来看一下,希望对大家有帮助。

在之前的文章《实用Word技巧分享:聊聊你没用过的“行号”功能》中,我们了解了Word中你肯定没用过的"行号”功能。今天继续实用Word技巧分享,看看Excel表格怎么借用Word进行分栏打印,快来收藏使用吧!

在之前的文章《实用Excel技巧分享:原来“定位功能”这么有用!》中,我们了解了定位功能的妙用。而今天我们聊聊合并后的单元格如何实现筛选功能,分享一种复制粘贴和方法解决这个问题,另外还会给大家分享一种合并单元格的不错的替代方式。

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于zenmm制作倒计时牌的相关内容,使用Excel中的日期函数结合按指定时间刷新的VBA代码,即可制作出倒计时牌,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于excel的相关知识,其中主要介绍了关于如何使用函数寻找总和为某个值的组合的问题,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于Excel的相关知识,其中主要介绍了关于XLOOKUP函数的相关知识,包括了常规查询、逆向查询、返回多列、自动除错以及近似查找等内容,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
