
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
插入一条记看看...
MySQL 中何存中文方法如下:
1、create table的时候加上:ENGINE=InnoDB DEFAULT CHARSET=gbk
例如:
CREATE TABLE t_department (
sid varchar(32) NOT NULL,
pid varchar(32) NOT NULL,
thedata varchar(50) NOT NULL
ENGINE=InnoDB DEFAULT CHARSET=gbk
2、打开MySQL目录下的my.ini文件,把里面所有的default-character-set选项设为GBK或者GB2312,保存后重启MySQL。
3、mysql数据库安装的时候。选择语言为gbk,这样在数据库中才可以存放中文。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)