Error 1071 42000
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack
Error 1071: Specified Key Was Too Long; Max Key Length Is 767 Bytes
Overflow the company Business Learn more about hiring developers or posting ads with us Stack error 1709 (hy000): index column size too large. the maximum column size is 767 bytes. Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community specified key was too long max key length is 1000 bytes mysql of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up mysql ERROR 1071 (Specified key was too long; max key length is 1000 bytes) in simple dump-import
Innodb_large_prefix
setting up vote 0 down vote favorite dump mysql db on server 1 $ mysql --version mysql Ver 14.14 Distrib 5.1.54, for debian-linux-gnu (x86_64) using readline 6.2 $ mysqldump -u root -p db > db.sql import on server 2 $ mysql --version mysql Ver 14.12 Distrib 5.0.95, for unknown-linux-gnu (x86_64) using readline 5.1 $ mysql -u root -p db < db.sql ERROR 1071 (42000) at line 807: Specified key was too
Mysql Innodb Increase Max Key Length
long; max key length is 1000 bytes I know there is a lot of questions and answers on this error but it still leaves me puzzled. Can it be a version problem? I suspect no. If I run it with --force option, it gets even wierder: ERROR 1071 (42000) at line 807: Specified key was too long; max key length is 1000 bytes ERROR 1146 (42S02) at line 847: Table 'db.users' doesn't exist ERROR 1146 (42S02) at line 848: Table 'db.users' doesn't exist ERROR 1146 (42S02) at line 849: Table 'db.users' doesn't exist ERROR 1146 (42S02) at line 850: Table 'db.users' doesn't exist what is going on? I mean apart from solving this, I would like to understand what settings affect a simple dump-import act and why can those settings not be explicit in my dump file and be set t import. I prefer not having to debug actual errors, this must be solveable on high level. UPDATE: SOLUTION as Frederic pointed me to the right direction. Basically my dump was trying to set db with INNODB engine, but mysql on server 2 had in /etc/my.cnf [mysqld] skip-innodb by simply deleting this option and restarting mysqld, my import ran without a croak. I am very sad such a simple thing like an unavailab
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or mysql max key length posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Mariadb Innodb_large_prefix
Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes innodb large prefix a minute: Sign up #1071 - Specified key was too long; max key length is 767 bytes up vote 194 down vote favorite 43 When I executed the following command: ALTER TABLE `mytable` ADD UNIQUE ( `column1` , `column2` ); http://stackoverflow.com/questions/10873870/mysql-error-1071-specified-key-was-too-long-max-key-length-is-1000-bytes-in-s I got this error message: #1071 - Specified key was too long; max key length is 767 bytes Information about column1 and column2: column1 varchar(20) utf8_general_ci column2 varchar(500) utf8_general_ci I think varchar(20) only requires 21 bytes while varchar(500) only requires 501 bytes. So the total bytes are 522, less than 767. So why did I get the error message? #1071 - Specified key was too long; max key length is 767 bytes mysql byte varchar mysql-error-1071 share|improve this question edited May http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes 23 '11 at 21:32 OMG Ponies 198k36356415 asked Nov 29 '09 at 3:18 Steven 5,2643480112 Because its not 520 bytes, but rather, 2080 bytes, which far exceeds 767 bytes, you could do column1 varchar(20) and column2 varchar(170). if you want a character/byte equiv, use latin1 –Rahly Dec 18 '15 at 0:21 add a comment| 17 Answers 17 active oldest votes up vote 137 down vote accepted 767 bytes is the stated prefix limitation for InnoDB tables - its 1,000 bytes long for MyISAM tables. According to the response to this issue, you can get the key to apply by specifying a subset of the column rather than the entire amount. IE: ALTER TABLE `mytable` ADD UNIQUE ( column1(15), column2(200) ); Tweak as you need to get the key to apply, but I wonder if it would be worth it to review your data model regarding this entity to see if there's improvements that would allow you to implement the intended business rules without hitting the MySQL limitation. share|improve this answer edited Oct 15 '14 at 20:20 The Alchemist 2,6901017 answered Nov 29 '09 at 3:52 OMG Ponies 198k36356415 To apply by specifying a subset of the column rather than the entire amount. A good solution. –Steven Nov 29 '09 at 4:14 @OMGPonies: Do you happen to know, if DB2/MSSQL/Oracle have the same limitation on index size? For example HSQL does not have such limitation... –dma_k Nov
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers http://dba.stackexchange.com/questions/49913/specified-key-was-too-long-max-key-length-is-1000-bytes-in-mysql-5-6 to any questions you might have Meta Discuss the workings http://logic.edchen.org/2014/12/how-to-resolve-error-1071-42000.html and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a max key question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the max key length top Specified key was too long; max key length is 1000 bytes in mysql 5.6 up vote 2 down vote favorite 1 one of the application server is internally creating the database on my mysql but when ever the following create table command gets executed CREATE TABLE ofRoster ( rosterID BIGINT NOT NULL, username VARCHAR(64) NOT NULL, jid VARCHAR(1024) NOT NULL, sub TINYINT NOT NULL, ask TINYINT NOT NULL, recv TINYINT NOT NULL, nick VARCHAR(255), PRIMARY KEY (rosterID), INDEX ofRoster_unameid_idx (username), INDEX ofRoster_jid_idx (jid) ) i am getting following error ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes i have set my default engine to MyISAM because i was getting following error in InnoDB specified key was too long max key length is 767 bytes my current engines are as follows +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | Engine | Support | Comment | Transactions | XA | Savepoints | +--------------------+---------+--------------------------------------------
using btree;
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes According to the official document MySQL :: MySQL 5.7 Reference Manual :: 14.6.7 Limits on InnoDB Tables. The limit is described as this: By default, an index key for a single-column index can be up to 767 bytes. The same length limit applies to any index key prefix. See Section 13.1.11, "CREATE INDEX Syntax". For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a UTF-8 character set and the maximum of 3 bytes for each character. The prefix limit can be raised under the following conditions: When the innodb_large_prefix configuration option is enabled, this length limit is raised to 3072 bytes, for InnoDB tables that use the DYNAMIC and COMPRESSED row formats. It appears that if we don't specify the index length for the string column explicitly, then the full length of this string column is applied, which could exceed the limit of 767 bytes. Let's go back to our case. mysql> desc table_name;
+--------------+------------------+------+-----+-------------------+...
| Field | Type | Null | Key | Default |...
+--------------+------------------+------+-----+-------------------+...
...
| facebook_url | varchar(512) | YES | | NULL |...
| twitter_url | varchar(512) | YES | | NULL |...
+--------------+------------------+------+-----+-------------------+...
9 rows in set (0.01 sec) OK, the full length of the string column is 512 characters, it may take up to 512 * 3 = 1536 bytes in UTF8 tables or 512 * 4 = 2048 bytes in UTF8MB4 tables. Now, let's do a simple math. For UTF8 tables, we should confine the number of characters to no more than the floor of 767 / 3 which is 255 on this column. For UTF8MB4 tables, the limit would be 767 / 4 = 191. Since our tables are all based on UTF8MB4, we should explicitly specify the length as such: mysql> create unique index idx_name_1 on table_name (facebook_url(191))