Laravel8.x laravel voyager 执行php artisan voyager:install报错:1071 Specified key was too long
执行数据库迁移文件时报错Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes
,对于这个错误已经很熟悉,解决方法 Larabel迁移文件时报SQLSTATE[42000]错误的解决方法 ,就是修改为191。但是修改了,还是报长度错误,怎么解决?
如下是我遇到的错误:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `translations`
add unique `translations_table_name_column_name_foreign_key_locale_unique`(`table_name`, `column_name`, `foreign_key`, `locale`))
可以看到报的还是长度错误,但是类型不一样了。这是存储引擎的原因,修改即可,解决方法如下:
// config/database.php
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
完整配置如下
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
// 修改引擎
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
我是温新
每天进步一点点,就一点点
请登录后再评论