Laravel-admin php artisan admin:install error reporting problem solution

Problem description: According to the installation steps of the official laravel-admin document, execute: php artisan admin:install An error was reported during installation.

In fact, the problem of creating special characters in the database is too long. Laravel 5.4 changed the default database character set. Now utf8mb4 includes support for storing emojis. If you are running MySQL v5.7.7 or higher, you don’t need to do anything.

When you try to run the migrations command on some MariaDB or some older versions of MySQL, you may encounter the following error:

D:\wwwroot\www.test.com>php artisan admin:install
Migration table created successfully.

In Connection.php line 664:

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


In Connection.php line 458:

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

The solution is to add default values ​​in app\Providers\AppServiceProvider.php, and you need to delete the database migrations and users tables. Re-execute: php artisan admin:install

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; //add fixed sql

class AppServiceProvider extends ServiceProvider
{
    /* *
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191); //add fixed sql
    }

    /* *
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
     }
}

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *