小滕的博客 | Laravel5.4项目遇到的坑:alter table `users` add unique `users_email_unique`(`email`))

[小滕的博客 | Laravel5.4项目遇到的坑:alter table users add unique users_email_unique(email))]

Laravel5.4项目遇到的坑:alter table `users` add unique `users_email_unique`(`email`))

1 year ago · 0 MIN READ
#PHP  #Laravel 

今天开始使用 Laravel5.4 做项目结果在执行 php artisan migrate 卡住了,总是报错:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

方法一

在网上查找了下资料,修改 config/database.php 文件,关键字搜索: utf8mb4 替换成 utf8 便可以了。

方法二

此方法原文链接:[](https://news.laravel-china.org/posts/544)https://news.laravel-china.org/posts/544

修改 app/Providers/AppServiceProvider.php 文件:

use Illuminate\Support\Facades\Schema;

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

That's All。(^ - ^)。

0 Comments - powered by utteranc.es

@anonymous

Write Preview

Nothing to preview

Styling with Markdown is supported Sign in to comment

···

xiao teng

[](https://github.com/Qsnh)


Original url: Access

Created at: 2018-10-12 13:51:03

Category: default

Tags: none

请先后发表评论
  • 最新评论
  • 总共1条评论
DeepMind

Rain酱

[linjinyu@localhost superdesk_boss]$ php artisan migrateMigration table created successfully.Migrating: 2014_10_12_000000_create_users_tableMigrated:  2014_10_12_000000_create_users_tableMigrating: 2014_10_12_100000_create_password_resets_tableMigrated:  2014_10_12_100000_create_password_resets_table

2018-10-12 13:53:16 回复