怎样往MYSQL输入汉字?

怎样往MYSQL输入汉字?,第1张

有两种方法...你试一下...不行的话加我的QQ

76558882

1.

修改

mysql

安装目录下的

my.ini

修改

default-character-set=latin1

把latin1

改为

gb2312

gbk

注意:

修改两处

CLIENT

SECTION

#

----------------------------------------------------------------------

#

#

The

following

options

will

be

read

by

MySQL

client

applications.

#

Note

that

only

client

applications

shipped

by

MySQL

are

guaranteed

#

to

read

this

section.

If

you

want

your

own

MySQL

client

program

to

#

honor

these

values,

you

need

to

specify

it

as

an

option

during

the

#

MySQL

client

library

initialization.

#

[client]

port=3306

[mysql]

default-character-set=latin1

//把

latin1

改为

gb2312或

gbk

#

SERVER

SECTION

#

----------------------------------------------------------------------

#

#

The

following

options

will

be

read

by

the

MySQL

Server.

Make

sure

that

#

you

have

installed

the

server

correctly

(see

above)

so

it

reads

this

#

file.

#

[mysqld]

#

The

TCP/IP

Port

the

MySQL

Server

will

listen

on

port=3306

#Path

to

installation

directory.

All

paths

are

usually

resolved

relative

to

this.

basedir="C:/Program

Files/MySQL/MySQL

Server

5.0/"

#Path

to

the

database

root

datadir="C:/Program

Files/MySQL/MySQL

Server

5.0/Data/"

#

The

default

character

set

that

will

be

used

when

a

new

schema

or

table

is

#

created

and

no

character

set

is

defined

default-character-set=latin1

//将latin1

改为

gb2312

gbk

2.

进入在命令提示符下登录mysql

输入

charset

gb2312

你再尝试使用

insert

into

插入一条记看看...

首先:

用show variables like “%colla%”;show varables like “%char%”;这两条命令查看数据库与服务端字符集设置

如果查看出来都是gbk2312,或 gbk,那么就只能支持简体中文,繁体和一些特殊符号是不能插入的,我们只有修改字符集为UTF-8,

修改方法如下:

用记事本或UitraEdit打开mysql数据库安装目录下的my.ini文件打开, 然后Ctrl+F搜索default-character-set,将后面的字符集修改为UTF8,注意要修改两个地方,一个事客户端的,一个是服务端的。

然后保存,重启mysql服务、、进去继续用show variables like “%colla%”;show varables like “%char%”;着两条语句查询一下字符集。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/6132989.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存