Error: #1071 - Specified key was too long; max key length is 1000 bytes - mysql 5.0.91

后端 未结 4 1005
攒了一身酷
攒了一身酷 2021-01-25 09:39

I am using mysql 5.0.91 and I need to save URLs ( some are small and some are very long ). I want to use varchar(2000) but I get an error:

#1

4条回答
  •  無奈伤痛
    2021-01-25 10:32

    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:

    use Illuminate\Support\Facades\Schema;
    
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }
    

提交回复
热议问题