MySQL数据库插入中文不成功

来源:百度知道 编辑:UC知道 时间:2024/06/17 21:07:54
create database bbs;

use bbs;

create table article
(
id int primary key auto_increment,
pid int,
rootid int,
title varchar(255),
cont text,
pdate datetime,
isleaf int
);

insert into article values (null, 0, 1, '蚂蚁大战大象', '蚂蚁大战大象', now(), 1);
insert into article values (null, 1, 1, '大象被打趴下了', '大象被打趴下了',now(), 1);
insert into article values (null, 2, 1, '蚂蚁也不好过','蚂蚁也不好过', now(), 0);
insert into article values (null, 2, 1, '瞎说', '瞎说', now(), 1);
insert into article values (null, 4, 1, '没有瞎说', '没有瞎说', now(), 0);
insert into article values (null, 1, 1, '怎么可能', '怎么可能', now(), 1);
insert into article values (null, 6, 1, '怎么没有可能', '怎么没有可能', now(), 0);
insert into article values (null, 6, 1, '可能性是很大的', '可能性是很大的', now(), 0);
insert into article values (

插入数据之前,先执行 set names gb2312;

估计是你在安装数据的时候 没有修改默认的编码属性

mysql安装的默认编码属性是latin什么的 总之是不支持中文的

你修改一下编码集就OK啦 不会修改 你可以重新安装一下

在安装过程中 注意修改那个default ...什么的 意思就是默认编码集的意思

你选择gb2312 或者gbk都可以的!!!

当mysql的某个字段编码不支持中文时,只要在该字段加上 character set utf8 就OK了

主要是因为编码不同的问题,一般mysql用的中文编码是utf-8,全部改成这个试试咯

可能你装mysql时,编码没有设为GB2312所以可能插进去后出乱码了。
方法1:可重新配一个mysql就行了
方法2:找到mysql中的一个my.ini打开后。把编码改为GB2312或GBK就行了