debugsqlMinor
MySql - ERROR 1071 Specified key was too long; max key length is 1000 bytes while restoring dump
Viewed 0 times
dumperrorkeywhilelengthlongtoorestoringmysqlmax
Problem
while trying to restore a MySql Dump, i get the following error:
any ideas?
ERROR 1071 (42000) at line 25: Specified key was too long; max key length is 1000 bytesany ideas?
Solution
You may to have adjust some VARCHAR length in some table based on the Character Set you are using.
That exact error message is actually posted as a bug report from Nov 2004, when in fact, it is not really a bug. That should direct you on how to adjust key lengths, especially your PRIMARY KEYs.
If you know which table is causing the
Step 01) mysqldump only database schema
Step 02) mysqldump only data
Step 03) Using vi or some other editor, edit the table's PRIMARY KEY to manually limit the PRIMARY KEY in such a way that the key does not exceed 1000 characters.
Step 04) Load the schema
Step 05) Load the data
You may have to resort to this if you cannot otherwise figure this out,
UPDATE 2012-01-23 11:43 EDT
Since you mentioned a certain table has the wrong storage engine, here is what you do:
Look above at Step 03. Go find the table in the file. Look for
UPDATE 2012-01-23 11:52 EDT
You should add this to to /etc/my.cnf
then run
However, the mysqldump will still have the
That exact error message is actually posted as a bug report from Nov 2004, when in fact, it is not really a bug. That should direct you on how to adjust key lengths, especially your PRIMARY KEYs.
If you know which table is causing the
Error 1071, you have to do the following:Step 01) mysqldump only database schema
mysqldump --routines --triggers --all-databases --no-data > MySQLSchema.sqlStep 02) mysqldump only data
mysqldump --all-databases --no-create-info > MySQLData.sqlStep 03) Using vi or some other editor, edit the table's PRIMARY KEY to manually limit the PRIMARY KEY in such a way that the key does not exceed 1000 characters.
Step 04) Load the schema
mysql -A < MySQLSchema.sqlStep 05) Load the data
mysql -A < MySQLData.sqlYou may have to resort to this if you cannot otherwise figure this out,
UPDATE 2012-01-23 11:43 EDT
Since you mentioned a certain table has the wrong storage engine, here is what you do:
Look above at Step 03. Go find the table in the file. Look for
ENGINE=MyISAM in the file and change it to ENGINE=InnoDB. Then, load the schema file first and the data file afterwards.UPDATE 2012-01-23 11:52 EDT
You should add this to to /etc/my.cnf
[mysqld]
default-storage-engine=InnoDBthen run
service mysql restart. If you cannot restart mysql at this time, run this in the mysql client:mysql> SET GLOBAL default_storage_engine = 'InnoDB';However, the mysqldump will still have the
ENGINE=MyISAM at the end of each CREATE TABLE. You will have to perform the 5-Step plan I mentioned above including changing the ENGINE=MyISAM to ENGINE=InnoDB. DO NOT CHANGE THAT FOR THE mysql DATABASE !!! Change only those tables that are yours.Code Snippets
mysqldump --routines --triggers --all-databases --no-data > MySQLSchema.sqlmysqldump --all-databases --no-create-info > MySQLData.sqlmysql -A < MySQLSchema.sqlmysql -A < MySQLData.sql[mysqld]
default-storage-engine=InnoDBContext
StackExchange Database Administrators Q#11393, answer score: 2
Revisions (0)
No revisions yet.