Home Database Mysql Tutorial 解决mysql导入还原时乱码的问题

解决mysql导入还原时乱码的问题

Jun 07, 2016 pm 05:55 PM
Garbled characters

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,这样中文就显示正常了
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve garbled word page numbers How to solve garbled word page numbers Jun 25, 2023 pm 03:23 PM

How to solve garbled word page numbers

How to solve Chinese garbled characters in Linux How to solve Chinese garbled characters in Linux Feb 21, 2024 am 10:48 AM

How to solve Chinese garbled characters in Linux

What to do if linux tty has Chinese garbled characters What to do if linux tty has Chinese garbled characters Mar 16, 2023 am 09:20 AM

What to do if linux tty has Chinese garbled characters

How to solve tomcat startup garbled code How to solve tomcat startup garbled code Dec 26, 2023 pm 05:21 PM

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 Chinese garbled characters in Windows 10 Jan 16, 2024 pm 02:21 PM

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

How to solve the problem of garbled characters in win11 system documents How to solve the problem of garbled characters in win11 system documents Jun 29, 2023 pm 06:29 PM

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

Solve the problem of garbled characters in win11 notepad Solve the problem of garbled characters in win11 notepad Jan 05, 2024 pm 03:11 PM

Solve the problem of garbled characters in win11 notepad

Editing method to solve the problem of garbled characters when opening dll files Editing method to solve the problem of garbled characters when opening dll files Jan 06, 2024 pm 07:53 PM

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

See all articles