MySQL Error: ER_TOO_LONG_KEY

1

I'm getting the error in MySQL and I do not know how to solve it.

Below is the output:

code: 'ER_TOO_LONG_KEY',
  errno: 1071,
  sqlMessage: 'Specified key was too long; max key length is 767 bytes',
  sqlState: '42000',
  index: 0,
  sql: 'alter table 'positions' add unique 'positions_name_unique'('name')' 
}

Image of the table structure:
- > link

The charset used is UTF-8.

    
asked by anonymous 06.06.2018 / 00:41

1 answer

2

Themaximumthatyoucanuseincolumnsutf8mb4(inINNODBtable)wouldbe191(767/4=191)becauseituses4bytespercharacter.

Decreasethevalueinname(200)sothatitstayswithinthelimit.

Moreinformationcanbefoundin official MySQL documentation

a> .

    
11.06.2018 / 23:56