mysql索引前缀长度在ubuntu中自动设置
我有下面的MyISAM表mysql索引前缀长度在ubuntu中自动设置,mysql,macos,ubuntu,indexing,mysqldump,Mysql,Macos,Ubuntu,Indexing,Mysqldump,我有下面的MyISAM表 mysql> show create table product_desc\G *************************** 1. row *************************** Table: product_desc Create Table: CREATE TABLE `product_desc` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `product_
mysql> show create table product_desc\G
*************************** 1. row ***************************
Table: product_desc
Create Table: CREATE TABLE `product_desc` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`product_id` int(10) unsigned DEFAULT '0',
`title` varchar(100) DEFAULT NULL,
`description` varchar(5000) DEFAULT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `title` (`title`,`description`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
但是,当我想用下面的命令更改表(添加索引)时,我得到了错误
mysql> ALTER TABLE product_desc ADD INDEX `description` (`description`);
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
奇怪的是,这只发生在MacOSX上,而不是我的ubuntu服务器上。因此,我检查服务器上的结果表,得到以下结果:
mysql> show indexes from product_desc;
+------------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| product_desc | 0 | PRIMARY | 1 | id | A | 5 | NULL | NULL | | BTREE | | |
| product_desc | 1 | description | 1 | description | A | 5 | 333 | NULL | YES | BTREE | | |
| product_desc | 1 | title | 1 | title | NULL | 1 | NULL | NULL | YES | FULLTEXT | | |
| product_desc | 1 | title | 2 | description | NULL | 1 | NULL | NULL | YES | FULLTEXT | | |
+------------------------+------------+-------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
6 rows in set (0.00 sec)
有趣的是
description
index会自动获得333前缀长度。所以我的问题是它是如何发生的?是否需要在MacOS my.cnf上设置任何配置变量以获得相同的结果?您的列太大,无法索引
前缀最长可达1000字节(InnoDB表为767字节)
这是一个MySql限制,不是特定于操作系统(而是特定于存储引擎)
你能给我看一下MacOS上的表格细节吗
您是否在两个系统上运行完全相同的MySQL主/次/发布版本?涉及哪些版本?在ubuntu mysql版本是:5.5.32-0ubuntu0.12.04.1,在MacOS版本是5.6.12,我在