mysql 5.0 在插入记录的时候遇到 Incorrect string value这个错误

作者:lizongbo 发表于:8:24 下午. 星期五, 6月 27th, 2008
版权声明:可以任意转载,转载时请务必以超链接形式标明文章和作者信息及本版权声明

修改 C:\Program Files\mysql\mysql Server 5.0\my.ini

mysqlmysqld的 default-character-set为gbk,

my.ini节选如下:
[mysql]

default-character-set=gbk

[mysqld]
port=3306

basedir=”C:/Program Files/mysql/mysql Server 5.0/”

#Path to the database root
datadir=”C:/Program Files/mysql/mysql Server 5.0/Data/”
default-character-set=gbk
default-storage-engine=MyISAM

然后重启数据库,重新创建数据库即可。

创建的数据库步骤如下:

在heidisql里,先运行  set names ‘gbk’,

然后运行建表sql。

然后就可以看到表的字段和内容,均为中文显示了。

其它关于mysql 的笔记:

1.在命令行下, 用 mysql -uroot连接到mysql服务器
2.SHOW DATABASES; 查看当前服务器已经有的数据库名字。
3.use test 表示连接到名叫”test”的数据库
4.show table;
查看该数据库中的表名。
5.查询记录
select * from topic limit 10,3;
表示从topic中的第11条记录开始,取出三条,
6 show status;
查看数据库配置的一些信息。
7.查看数据库版本
SELECT VERSION();

8.创建数据库
CREATE DATABASE `testtable`; /*!40100 CHARACTER SET utf8 COLLATE utf8_general_ci */

9.创建表

CREATE TABLE `testtable`.`testtablemsg` (`testtabletype` VARCHAR (50)
DEFAULT ‘fc_ssq’ NOT NULL, `testtableday` VARCHAR (50) DEFAULT ‘08024′ NOT NULL,
`testtablename` VARCHAR (50) DEFAULT ‘福’ NOT NULL, PRIMARY KEY(`testtabletype`,`testtableday`))
COMMENT = “开奖公告” TYPE = InnoDB /*!40100 DEFAULT CHARSET utf8 COLLATE utf8_general_ci */;

10.查看表字段
SHOW /*!32332 FULL */ COLUMNS FROM `testtablemsg`;
11.查看主键信息
SHOW KEYS FROM `testtablemsg`;

12.导入sql到指定的数据库:

mysql -uroot -p testtable < /data/lizongbo_tmp/import/testtable.sql

13.查看所有连接

SHOW FULL PROCESSLIST;

14.导入sql文件的时候遇到错误信息

ERROR 1153 at line 6388: Got a packet bigger than ‘max_allowed_packet’

然后查看对应参数:

mysql> show VARIABLES like ‘%max%’;
+———————————+———————-+
| Variable_name                   | Value                |
+———————————+———————-+
| ft_max_word_len                 | 254                  |
| ft_max_word_len_for_sort        | 20                   |
| innodb_max_dirty_pages_pct      | 90                   |
| innodb_max_purge_lag            | 0                    |
| max_allowed_packet              | 1047552              |
+———————————+———————-+

于是修改
mysql> set max_allowed_packet=4047552;
Query OK, 0 rows affected (0.00 sec)

Tags: mysql

Related posts

Tags:

recent related 12 searches :

本文发表于 on 星期五, 6月 27th, 2008 at 8:24 下午 and is filed under mysql, 数据库. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply