I have the following error. Someone is understanding why?
php artisan migrate
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`))
create_users_table.php
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name',255);
$table->string('email',255)->unique();
$table->string('password',255);
$table->rememberToken();
$table->timestamps();
});
you have to do is edit your AppServiceProvider.php on App\Providers\AppServiceProvider
file and inside the boot method set a default string length:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Then drop the database manually then composer dump-autoload
and php artisan migrate
Edit AppServiceProvider.php
file, you will find this file in app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
Then run
composer update
on your terminal. Then try migrating your script, It would solve your problem.
Thanks all message
Resolved with next code:
in config/database.php in mysql section
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
and replace them with with
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With