Someday ago, i wan working on my new laravel 5.5 application in my new system, with new configuration. I was simply installed laravel 5.5 app and then i created mysql database and then i run migration, but i got following error on my terminal.
"[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`))"
"[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes"
After this i checked my migration but it was perfect syntax followed, i was thinking what will be issued. after debug i found issue was in unique() of migration. So i require to fix then, after i google search and found the perfect solution set string length on AppServiceProvider.
So let's add this way :
app/Providers/AppServiceProvider.php
<?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()
{
Schema::defaultStringLength(191);
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
After i set Schema default string length, i solved my issue you can try this too.
I hope you found best solution....
Do you like below Tutorials ?
- How to Open URL in New Tab using Jquery?
- Laravel 7.x and 6.x Routing Tutorial
- Ng Bootstrap Modal in Angular 8 Example
- Bootstrap 4 Datepicker in Angular 9/8 Example
- Disable Registration Route in Laravel
- Bootstrap Timepicker in Angular Example
- Count Number of Pages in PDF - PHP Script
- Digital Signature PHP Script Example