behnampmdg3's avatar

Specified key was too long; max key length is 767 bytes

Hi;

Importing the database and Sequel pro says

Specified key was too long; max key length is 767 bytes

What is the right way of setting that globally so I don't have to do it for every table?

I don't wanna just change core files like /etc/my.conf.d without checking first.

Thanks

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

Laravel uses the utf8mb4 character set by default, which includes support for storing "emojis" in the database. If you are running a version of MySQL older than the 5.7.7 release or MariaDB older than the 10.2.2 release, you may need to manually configure the default string length generated by migrations in order for MySQL to create indexes for them. You may configure this by calling the Schema::defaultStringLength method within your AppServiceProvider:

public function boot()
{
    Schema::defaultStringLength(191);
}

https://laravel.com/docs/master/migrations#creating-indexes

Or... upgrade your MySQL/MariaDB version

Please or to participate in this conversation.