I try to create a login in laravel 5.6 and at the time of making the migration I get the following error
Surely your version of MySQL is less than 5.7; then in the fields of index type the length is not specified, you can solve it in the following ways:
Schema :: defaultStringLength (191);
And at the same time in the upper part just below the namespace App \ Providers, it also declares this line of code
use Illuminate \ Support \ Facades \ Schema;
php
<?php
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email',100)->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
In the previous code, notes as in the line of the string email I pass after the name also a length of 100
Note: you should upload code in text to make it easier.
The error occurs in certain database engines due to the character set and coding, depending on the coding, each char can occupy 1, 2, or 4 bytes (utf8, utf8mb4) and this makes the maximum limit reach type varchar
to define the unique key.
On each line that says $table->string
try adding the maximum number of characters (190)
for example:
$table->string('name', 190);
more info: link