进入安装目录下的 my.ini修改配置,
有两个地方需要修改,一个是client端的还有一个是server端的
Sql代码
- #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=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 6.0/”
- #Path to the database root
- datadir=“C:/Program Files/MySQL/MySQL Server 6.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=gbk//这个地方
其实这两个地方弄好了,未必就能插入中文,
还要在创建数据库的时候 指定 default charset=gbk
创建表的时候最好也加上。
create table data(
id int primary key auto_increment,
sid varchar(256) not null,
name varchar(256) not null,
longitude decimal(10,6) not null,
latitude decimal(9,6) not null,
jam_level integer(1) not null,
description text,
insert_time timestamp not null,
update_time timestamp not null
)default charset=gbk
按以上操作后,中文可以插入mysql数据库中了(最好此时重启下mysql服务:net stop mysql,net start mysql)。