laravel-admin php artisan admin:install报错问题解决办法

问题描述:根据laravel-admin官方文档安装步骤,执行:php artisan admin:install 安装时报错:

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

问题原因:laravel-admin1.6要求mysql数据库版本^5.7以上。

解决办法:将以下文件中的

vendor\laravel\framework\src\Illuminate\Database\Schema\Builder.php

public static $defaultStringLength = 255;

修改为:250以下

public static $defaultStringLength = 250;

需要删除数据库migrations、users表。

重新执行:

php artisan admin:install

安装成功:

$ php artisan admin:install
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table
Migrating: 2016_01_04_173148_create_admin_tables
Migrated: 2016_01_04_173148_create_admin_tables
Database seeding completed successfully.
Admin directory was created: \app\Admin
HomeController file was created: \app\Admin/Controllers/HomeController.php
AuthController file was created: \app\Admin/Controllers/AuthController.php
ExampleController file was created: \app\Admin/Controllers/ExampleController.php
Bootstrap file was created: \app\Admin/bootstrap.php
Routes file was created: \app\Admin/routes.php

启动服务后,在浏览器打开 http://localhost/admin/ ,使用用户名 admin 和密码 admin登陆.

你可能感兴趣的:(学习总结)