mysql保存中文乱码的原因和解决办法_MySQL
bitsCN.com
当你遇到这个mysql保存中文乱码问题的时候,期待找到mysql保存中文乱码的原因和解决办法这样一篇能解决问题的文章是多么激动人心。
也许30%的程序员会选择自己百度,结果发现网友已经贴了很多类似mysql 中文乱码、php mysql 中文乱码、mysql5.5中文乱码、mysql 乱码、mysql乱码问题、mysql jsp 乱码、mysql jdbc 乱码、mysql 查询乱码、mysql 导入数据乱码等一系列问题,到底哪个是自己要找的能解决自己问题的呀?15%的程序员一看就懵了,剩下15%的程序员自己摸索或求教别人了。70%的程序员干脆不干了,干不动咱还是程序员,这种浪费生命的事情让别人干去把,呵呵。
其实mysql的乱码问题,说复杂也非常地负责,说简单简单的不行!区别就在于明白mysql乱码的本质原因,本文就从这个角度目的让煞笔程序员都掌握如何处理这个乱码问题。 (1)网站本身的编码。这不多说了,自己看看设置对了没,比如我设置的GBK就检查下编码是不是GBK。(一般通过文件右击属性来看,或建立工程的时候来统一设置)
(2)数据库连接字符串的编码。比如java中我连接mysql的相关语句如下: public static String driverName = "com.mysql.jdbc.Driver";
public static String userName = "root";
public static String userPasswd = "123456";
public static String dbName = "myBook";
public static String url = "jdbc:mysql://localhost/" + dbName + "?user="
+ userName + "&password=" + userPasswd
+ "&useUnicode=true&characterEncoding=GBK";。。。。。Class.forName(driverName).newInstance();
connection = (Connection) DriverManager.getConnection(url);如上面的代码中,加粗的就是我要说的部分,可以设置为你想要的字符串类型,这里设置的是GBK,这仅仅是java语言的示例,其他语言asp、php原理是一样的都有这样的数据库字符串链接关于字符集的配置,不会就查查手册或百度一下,这个很容易找到,如果百度还找不到,那360干他也对。
(3)mysql的字符集设置。 这个是重点了,一般都是在这里搞错而出现了mysql乱码。 mysql编码设置可以分为三种设置:数据库的编码、表的编码、和字段的编码。 a、数据库的编码: 在sqlyog工具中操作把,右击数据库点击更改数据库,如图
设置就可以了,煞笔不煞笔,简单不简单。 b、表的编码: mysql很扯淡的是,表级别也设置了编码,说说咋设置把 。
右击要修改编码的表,点击更改表如上图,点了以后如下图:
点高级属性,表的字符编码设置很煞笔很简单,看到了把。记得修改完毕后,一定要点击Alter才行呀!这个按钮很容易被忽略,操蛋的sqlyog呀! c、字段的编码: mysql确实很扯淡,字段都有编码设置,还是上面的更改表,不过不点高级属性了。看图:
坑爹的默认不显示,对就是在右下角呢!看到了把,把对号取消把,取消后你看到了下图:
终于看到了字段后面跟的字符编码设置,他奶奶的熊,终于都找全了。设置把。记得修改完毕后,一定要点击Alter才行呀!这个按钮很容易被忽略,操蛋的sqlyog呀!
最后再出一个绝招把: SHOW CREATE TABLE 表名CREATE TABLE `wen` (
`id` int(8) DEFAULT NULL,
`bookid` int(8) DEFAULT NULL,
`title` varchar(200) COLLATE gbk_bin DEFAULT NULL,
`content` longtext COLLATE gbk_bin
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_bin CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC
bitsCN.com

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Call of Duty Warzone is a newly launched mobile game. Many players are very curious about how to set the language of this game to Chinese. In fact, it is very simple. Players only need to download the Chinese language pack, and then You can modify it after using it. The detailed content can be learned in this Chinese setting method introduction. Let us take a look together. How to set the Chinese language for the mobile game Call of Duty: Warzone 1. First enter the game and click the settings icon in the upper right corner of the interface. 2. In the menu bar that appears, find the [Download] option and click it. 3. Select [SIMPLIFIEDCHINESE] (Simplified Chinese) on this page to download the Simplified Chinese installation package. 4. Return to the settings

VSCode Setup in Chinese: A Complete Guide In software development, Visual Studio Code (VSCode for short) is a commonly used integrated development environment. For developers who use Chinese, setting VSCode to the Chinese interface can improve work efficiency. This article will provide you with a complete guide, detailing how to set VSCode to a Chinese interface and providing specific code examples. Step 1: Download and install the language pack. After opening VSCode, click on the left

Excel spreadsheet is one of the office software that many people are using now. Some users, because their computer is Win11 system, so the English interface is displayed. They want to switch to the Chinese interface, but they don’t know how to operate it. To solve this problem, this issue The editor is here to answer the questions for all users. Let’s take a look at the content shared in today’s software tutorial. Tutorial for switching Excel to Chinese: 1. Enter the software and click the "File" option on the left side of the toolbar at the top of the page. 2. Select "options" from the options given below. 3. After entering the new interface, click the “language” option on the left

How to display Chinese characters correctly in PHPDompdf When using PHPDompdf to generate PDF files, it is a common challenge to encounter the problem of garbled Chinese characters. This is because the font library used by Dompdf by default does not contain Chinese character sets. In order to display Chinese characters correctly, we need to manually set the font of Dompdf and make sure to select a font that supports Chinese characters. Here are some specific steps and code examples to solve this problem: Step 1: Download the Chinese font file First, we need

Title: An effective way to repair Chinese garbled characters in PHPDompdf. When using PHPDompdf to generate PDF documents, garbled Chinese characters are a common problem. This problem usually stems from the fact that Dompdf does not support Chinese character sets by default, resulting in Chinese content not being displayed correctly. In order to solve this problem, we need to take some effective ways to fix the Chinese garbled problem of PHPDompdf. 1. Use custom font files. An effective way to solve the problem of Chinese garbled characters in Dompdf is to use

1. How can you make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! 1. Activate basic rights and interests: original articles can earn profits by advertising, and videos must be original in horizontal screen mode to earn profits. 2. Activate the rights of 100 fans: if the number of fans reaches 100 fans or above, you can get profits from micro headlines, original Q&A creation and Q&A. 3. Insist on original works: Original works include articles, micro headlines, questions, etc., and are required to be more than 300 words. Please note that if illegally plagiarized works are published as original works, credit points will be deducted, and even any profits will be deducted. 4. Verticality: When writing articles in professional fields, you cannot write articles across fields at will. You will not get appropriate recommendations, you will not be able to achieve the professionalism and refinement of your work, and it will be difficult to attract fans and readers. 5. Activity: high activity,

Some friends may accidentally set it to English when installing the system. As a result, all the interfaces are changed to English and they cannot be understood. In fact, we can set the language in the control panel and change the language to Chinese. Let’s take a look at how to change it. How to change the language in win7 to Chinese 1. First click the button in the lower left corner of the screen, and then select "Control Panel" 2. Find "Changedispalylanguage" under "Clock, Language, and Region" 3. Click "English" below to select from the drop-down menu Simplified Chinese. 4. After confirmation, click "Logoffnow" to log out and restart the computer. 5. After coming back

"WWE2K24" is a racing sports game created by Visual Concepts and was officially released on March 9, 2024. This game has been highly praised, and many players are eagerly interested in whether it will have a Chinese version. Unfortunately, so far, "WWE2K24" has not yet launched a Chinese language version. Will wwe2k24 be in Chinese? Answer: Chinese is not currently supported. The standard version of WWE2K24 in the Steam Chinese region is priced at 199 yuan, the deluxe version is 329 yuan, and the commemorative edition is 395 yuan. The game has relatively high configuration requirements, and there are certain standards in terms of processor, graphics card, or running memory. Official recommended configuration and minimum configuration introduction:
