Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 4 SQLSTATE[42000] Specified key was too long

I am trying to create database from Entity in Symfony 4. However the result is:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

I know this is because it is trying to use utf8mb4 charset and utf8mb4_unicode_ci collation. I've tried to replace my doctrine.yaml file to utf8 and utf8_unicode_ci as well as:

@ORM\Table(name="users", options={"collate"="utf8_unicode_ci", "charset"="utf8", "engine"="MyISAM"})

But it's still trying to use utf88mb4. How can I force it to use utf8?

like image 397
Janusz Kubala Avatar asked Jun 09 '18 06:06

Janusz Kubala


1 Answers

Hi i get the same error : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

I fix it with change length to 191 like this : @ORM\Column(type="string", length=191, unique=true)

like image 131
Adil El Attary Avatar answered Sep 28 '22 20:09

Adil El Attary