Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 1071: Specified key was too long; max key length is 1000 bytes #400

Open
GameO7er opened this issue Aug 5, 2019 · 1 comment
Open

Comments

@GameO7er
Copy link

GameO7er commented Aug 5, 2019

After running php artisan panel:install it gives me :

Migrating: 2014_11_16_205658_create_admins_table
Migrated:  2014_11_16_205658_create_admins_table (0.18 seconds)
Migrating: 2014_12_02_152920_create_password_reminders_table

   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 `password_reminders` add
 index `password_reminders_email_index`(`email`))

and here is Exception trace:


  1   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
      C:\wamp\www\Project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  2   PDOStatement::execute()
      C:\wamp\www\Project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

  Please use the argument -v to see more details.

admins , migrations , password_reminders have been created successfully with 1 row except password_reminders which have no rows.

@GameO7er
Copy link
Author

GameO7er commented Aug 5, 2019

If anybody facing same problem, Please follow the below steps to fix the issue:

  1. Update the "config/database.php" for 'mysql'

'engine' => null,

to

'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',

= -= - = - = - = - = - =

  1. Update the app/Providers/AppServiceProvider.php with
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // Specified key was too long error, Laravel News post:
        Schema::defaultStringLength(191);
    }

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

= -= - = - = - = - = - =

  1. Execute Command:
php artisan cache:clear
php artisan config:clear
php artisan panel:install

Now, everything should works! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant