This is very old MySQL issue. MySQL engine like InnoDB or MyISAM has their own limit on the length of the columns where indexing can be applied. Usually it is 1000 for MyISAM and 767 for InnoDB. Problem occures when user try to change the length of the column where indexing was already applied or try to implement indexing on a column where length of column is already greater than 1000.
This problem can be solved in two ways:
1. Set the properties of MySQL engine. (It will only work for mysql 5.6+).
This problem can be solved in two ways:
1. Set the properties of MySQL engine. (It will only work for mysql 5.6+).
- show engines;(Get the current Engine - Only to check).
- show variables like 'innodb%'; (Get current engines properties)
- Set properties as:
- innodb_large_prefix=on;
- innodb_file_format=barracuda;
- innodb_file_per_table=true;
- Run the alter command.
2. Set MySQL to no engine mode.
- SELECT @@SESSION.sql_mode; (Check current SQL mode)
- SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; (Set SQL mode to no engine)
- run your alter command.
- Again set back to engine mode