본문 바로가기
MySql

MySQL Mysql::Error: Specified key was too long; max key length is 1000 bytes

by 베이스 공부 2020. 11. 13.
반응형
script/generate acts_as_taggable_on_migration
rake db:migrate

원인

Mysql::Error: Specified key was too long; max key length is 1000 bytes: CREATE  INDEX `index_taggings_on_taggable_id_and_taggable_type_and_context` ON `taggings` (`taggable_id`, `taggable_type`, `context`)

어떻게해야합니까?

내 데이터베이스 인코딩은 다음과 같습니다.

mysql> SHOW VARIABLES LIKE 'character\_set\_%';
+--------------------------+--------+
| Variable_name            | Value  |
+--------------------------+--------+
| character_set_client     | latin1 | 
| character_set_connection | latin1 | 
| character_set_database   | utf8   | 
| character_set_filesystem | binary | 
| character_set_results    | latin1 | 
| character_set_server     | latin1 | 
| character_set_system     | utf8   | 
+--------------------------+--------+
7 rows in set (0.00 sec)

 

해결 방법

 

이것은 전적으로 MySQL 문제입니다.

MySQL에는 MyISAM, InnoDB, 메모리 등 다른 엔진이 있습니다.


상한값에 도달했을 때 일부 인덱싱을 수용하기 위해 열 데이터 유형의 일부와 관련하여 인덱스를 정의 할 수 있습니다.

CREATE INDEX example_idx ON YOUR_TABLE(your_column(50))

your_column VARCHAR (100) 이라고 가정하면 위 예제의 색인은 처음 50 자에만 있습니다. 50 번째 문자를 초과하는 데이터를 검색하면 인덱스를 사용할 수 없습니다.

 

참조 페이지 https://stackoverflow.com/questions/3489041

 

 

반응형

댓글