但是MYSQL里不能直接插图中文了 mysql> insert into Goods values ('xxxx0000','zzz','product/book1.bmp','2','服装' ,10,'xxxxx'); ERROR 1406 (22001): Data too long for column 'g_type' at row 1 mysql>
谢谢了 我将MYsql的my.ini文件改成了 port=3306 [mysql] default-character-set=gb2312 # 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="E:/Program Files/MySql/MYSQL5/"#Path to the database root datadir="E:/Program Files/MySql/MYSQL5/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=utf8
在工程上右键->Properties->Text file encoding 选中Other,然后选中和数据库一致的编码。建议把数据库和程序都设置为UTF-8。
mysql> insert into Goods values ('xxxx0000','zzz','product/book1.bmp','2','服装'
,10,'xxxxx');
ERROR 1406 (22001): Data too long for column 'g_type' at row 1
mysql>
port=3306
[mysql]
default-character-set=gb2312
# 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="E:/Program Files/MySql/MYSQL5/"#Path to the database root
datadir="E:/Program Files/MySql/MYSQL5/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=utf8