MySQL 4.0.21 使用注意事项
1、max_allowed_packet = 16M,缺省为1M
这涉及BLOB等最大,通常要修改。
2、没有仔细看下面这段,这在MySQL的manual.html中有。建表时要用LONGBLOB 和LONGTEXT 。
BLOB
TEXT
A BLOB or TEXT column with a maximum length of 65,535 (2^16 -1) characters.
MEDIUMBLOB
MEDIUMTEXT
A BLOB or TEXT column with a maximum length of 16,777,215 (2^24 - 1) characters.
LONGBLOB
LONGTEXT
A BLOB or TEXT column with a maximum length of 4,294,967,295 or 4GB (2^32 - 1) characters.
3、中文问题,MySQL服务器就是缺省的latin1编码,不用任何设置。
在windows中文版上,linux上没有测试过。
数据库驱动 com.mysql.jdbc.Driver (org.gjt.mm.mysql.Driver用本方法无效)
jdbc:mysql://localhost/risenet?useUnicode=true&characterEncoding=gb2312
在xml中不要直接使用“&”,需要使用XML转意字符:&
4、缺省的storage engine是MyISAM,需要修改为InnoDB。
在运行时修改可以用:set table_type=InnoDB
用show variables可以查看当前的storage engine(也就是table_type)。
将mysql.ini中的关于InnoDB的部分的注释去掉。
Uncomment the following if you are using InnoDB tables
5、建立外键时发生错误,需要先建立index才可以建立外键。在 4.1.2 及以上的版本中,将自动建立index。
If MySQL reports an error number 1005 from a CREATE TABLE statement, and the error message string refers to errno 150, this
means that the table creation failed because a foreign key constraint was not correctly formed. Similarly, if an ALTER TABLE
fails and it refers to errno 150, that means a foreign key definition would be incorrectly formed for the altered table.
Starting from MySQL 4.0.13, you can use SHOW INNODB STATUS to display a detailed explanation of the latest InnoDB foreign key
error in the server.
------------------------
LATEST FOREIGN KEY ERROR
------------------------
041024 10:48:44 Error in foreign key constraint of table `risenet/office_workflowtracking`:
There is no index in table `risenet/office_workflowtracking` where the columns appear
as the first columns. Constraint:
FOREIGN KEY (Workflow_GUID) REFERENCES Office_WorkflowDefine(Workflow_GUID)
)
See http://www.innodb.com/ibman.php for correct foreign key definition.
------------
InnoDB needs indexes on foreign keys and referenced keys so that foreign key checks can be fast and not require a table scan.
Starting with MySQL 4.1.2, these indexes are created automatically. In older versions, the indexes must be created explicitly
or the creation of foreign key constraints will fail.
本文介绍了MySQL 4.0.21的使用注意事项,包括修改max_allowed_packet参数、建表使用LONGBLOB和LONGTEXT、解决中文编码问题、修改存储引擎为InnoDB,以及建立外键需先建索引等内容,还提及了相关配置和错误处理方法。
1591

被折叠的 条评论
为什么被折叠?



