【问题标题】:voyager php artisan voyager:install --with-dummy errorvoyager php artisan voyager:install --with-dummy 错误
【发布时间】:2017-10-15 02:29:58
【问题描述】:

[Illuminate\Database\QueryException] SQLSTATE[42000]:语法错误 或访问冲突:1071 指定的密钥太长;最大密钥长度 为 1000 字节(SQL: alter table translations add unique translations_table_name_column_name_foreign_key_locale_unique(table_ name, column_name, foreign_key, locale))

[Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 1000 字节

[PDO异常] SQLSTATE[42000]:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 1000 字节

AppServiceProvider.php这种方法不起作用我无法修复这个错误,有什么方法可以修复它?

use Illuminate\Support\Facades\Schema;

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

【问题讨论】:

    标签: php mysql laravel voyager


    【解决方案1】:

    改变

    use Illuminate\Support\Facades\Schema;
    

    到

    use Schema;
    

    【讨论】:

      【解决方案2】:

      当我尝试安装 voyager 时,这发生在我身上。经过几次挖掘,我发现这两个答案有效。

      解决方案 01

      * /config/database.php *
      
      'mysql' => [
          ...,
          ...,
          'engine' => 'InnoDB',
       ] 
      

      解决方案 02
      编辑 config 文件夹中的 database.php 文件。(与上述答案相同的文件)只需编辑,

      'charset' => 'utf8mb4',
      'collation' => 'utf8mb4_unicode_ci', 
      

      到

      'charset' => 'utf8',
      'collation' => 'utf8_unicode_ci',
      

      我从Laravel Migration Error: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes 问题答案中找到了这些。所以所有的功劳都应该归功于@dexterb 和@Koushik Das

      【讨论】:

        猜你喜欢
        • 2021-01-13
        • 2020-11-12
        • 2019-06-13
        • 2023-03-16
        • 2023-03-30
        • 2017-03-20
        • 2017-12-22
        • 2020-11-27
        • 2016-01-29
        相关资源
        最近更新 更多