When we migration of the table after the installation of latest laravel that time we face this type of an error.

Because it's not 520 bytes, but rather, 2080 bytes, which far exceeds 767 bytes, so we are facing this type of error.

Syntax error or access violation, #1071 - Specified key was too long; max key length is 767 bytes, PHP artisan migrate command error, long max key length is 767 bytes, syntax error or access violation 1071, MySQL error

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 E:\xampp\htdocs\lara_auth\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
    661|         // If an exception occurs when attempting to run a query, we'll format the error
    662|         // message to include the bindings with SQL, which will make this exception a
    663|         // lot more helpful to the developer instead of just the database's errors.
    664|         catch (Exception $e) {
  > 665|             throw new QueryException(
    666|                 $query, $this->prepareBindings($bindings), $e
    667|             );
    668|         }
    669|

  Exception trace:

  1   PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
      E:\xampp\htdocs\lara_auth\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

  2   PDOStatement::execute()
      E:\xampp\htdocs\lara_auth\vendor\laravel\framework\src\Illuminate\Database\Connection.php:459

  Please use the argument -v to see more details.

Now. let's go we will solve the above error. first open the AppServiceProvider.php file from the app/Providers/ directory. after then we will load the schema "use Illuminate\Support\Facades\Schema;" on top header and set the "Schema::defaultStringLength(191);" into boot method.

You can see below code, therefore, then you can better understand.

<?php

namespace App\Providers;

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

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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
        Schema::defaultStringLength(191);
    }
}
?>

After the above changes, you can again migrate the table and then it will be successfull migrated.