Jaq*_*arh 1 php laravel laravel-5.2
我通过在命令提示符窗口中执行这些代码行来启动我的Laravel项目.
cd C:\xampp\htdocs
composer global require laravel/installer
laravel new iezon
Run Code Online (Sandbox Code Playgroud)
然后我执行了命令来构建身份验证方案,我还没有编辑任何东西.
artisan make:auth
Run Code Online (Sandbox Code Playgroud)
然后我转到我的配置文件夹,在里面database.php,我mysql用.env覆盖它的文件改为正确的信息.
现在,我使用以下命令创建迁移表以检查我与数据库的连接:
php artisan migrate:install
Run Code Online (Sandbox Code Playgroud)
并安装我的表(默认用户表):
php artisan migrate:fresh
Run Code Online (Sandbox Code Playgroud)
然后在这个调试中抛出一个错误:
Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException : 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`))
at C:\xampp\htdocs\iezon\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
C:\xampp\htdocs\iezon\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
2 PDOStatement::execute()
C:\xampp\htdocs\iezon\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
Run Code Online (Sandbox Code Playgroud)
任何想法我缺少什么命令或做错了什么?我没有使用正确的信息更改database.php文件和.env文件以外的任何文件内容mysql.我怎样才能解决这个问题?
Go To AppServiceProvider.php in ```app\Providers```
Run Code Online (Sandbox Code Playgroud)
并boot()通过添加此行进行更改
\Schema::defaultStringLength(191);
function boot()
{
\Schema::defaultStringLength(191);
}
Run Code Online (Sandbox Code Playgroud)
Laravel utf8mb4默认使用字符集,其中包括支持在数据库中存储"emojis".如果您运行的是早于5.7.7发行版的MySQL 版本或早于发行版的MariaDB 10.2.2,您可能需要手动配置迁移生成的默认字符串长度,以便MySQL为它们创建索引.您可以通过调用Schema::defaultStringLength您的方法来配置它AppServiceProvider
| 归档时间: |
|
| 查看次数: |
56 次 |
| 最近记录: |