解决mysql导入还原时乱码的问题
sql文件,直接记事本方式打开,中文显示正常,还原导入后,发现中文是乱码
解决方法:第一步:还原时建立数据库和表都为utf8格式(建议utf8,当然gbk或者gb2312也行)
代码如下:
CREATE DATABASE `shegongku` DEFAULT CHARACTER SET utf8
CREATE TABLE `members` (
`uid` mediumint(8) unsigned NOT NULL default '0',
`username` varchar(15) NOT NULL default '',
`password` varchar(40) NOT NULL default '',
`salt` varchar(16) default NULL,
`email` varchar(60) NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
第二部,将sql文件的编码转换下,转成utf8格式,可以notepad2,也可以用UltraEditor进行转换,再在第一行sql文件的添加一行 set names utf8 保存。
第三部,导入。一般就不会出现乱码了,这时如果你在 终端cmd下再次查询发现还是乱码的话,这个不是数据库问题,而是显示的问题,在终端里输入 set names gbk,这样中文就显示正常了

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

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

How to solve garbled word page numbers

How to solve Chinese garbled characters in Linux

What to do if linux tty has Chinese garbled characters

How to solve tomcat startup garbled code

How to solve the problem of Chinese garbled characters in Windows 10

How to solve the problem of garbled characters in win11 system documents

Solve the problem of garbled characters in win11 notepad

Editing method to solve the problem of garbled characters when opening dll files
