Skip to main content

laravel php artisan migrate Migrating: 2014_10_12_000000_create_users_table 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`))

Sanjay Tech solutions


php artisan migrate
Migrating: 2014_10_12_000000_create_users_table

   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`))




this probles with database drive provider 

i have resolved error with 3 solution 



solution 1

 you need to create database with type " utf8_unicode_ci   "  




solution 2

change in config/database.php file
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',


solution  3


Add following code to your project file  AppServiceProvider.php (/app/Providers/AppServiceProvider.php)
use Illuminate\Support\Facades\Schema; //NEW: Import Schema

function boot()
{
    Schema::defaultStringLength(191); //NEW: Increase StringLength
}

Comments

Popular posts from this blog

How to delete Torrent power account

Sanjay Tech solutions 3 easy tips to delete torrent power account  Step 1 : login in to your account Step 2 : click on more profile settings Step 3 : you see red button with deactivate account click then enter your password Your account deactivate 

Anaconda update error PermissionError(13, 'Permission denied')

sanjay@luck:~$ conda update -n base conda Solving environment: done ## Package Plan ##   environment location: /home/sanjay/anaconda3   added / updated specs:     - conda The following packages will be UPDATED:     conda: 4.4.10-py36_0 --> 4.5.4-py36_0 Proceed ([y]/n)? y Preparing transaction: done Verifying transaction: done Executing transaction: failed ERROR conda.core.link:_execute(481): An error occurred while uninstalling package 'defaults::conda-4.4.10-py36_0'. PermissionError(13, 'Permission denied') Attempting to roll back. Rolling back transaction: done PermissionError(13, 'Permission denied') =========== you need to give a writable directory permission. on anaconda install directory. --> $ sudo chmod -R 755 anaconda3 sanjay@luck:~$ sudo chmod -R 777 anaconda3/  ============== sanjay@luck:~$ conda update anaconda-navigator Solving environment: done ## Package Plan ##   environment location: /home/sanjay/anaconda3   added / u