Press ESC to close

Manoj Bist

Laravel – SYNTAX ERROR OR ACCESS VIOLATION – SPECIFIED KEY WAS TOO LONG

Laravel 6 – Syntax error or access violation

Laravel has made a change to the default database character set, and it’s now utf8mb4 which includes support for storing emojis. This only affects new applications and as long as you are running MySQL v5.7.7 and higher you do not need to do anything.
For those running MariaDB or older versions of MySQL you may hit this SYNTAX ERROR OR ACCESS VIOLATION error when trying to run migrations:
Here is how we can solve this problem.
There is a simple step to fix this problem.
Step 1. Go to your project root directory
Step 2. Open config directory
Step 3. Now open database.php file using your favorite text editor or code editor, mine is a sublime text
Step 4.  find Mysql connection setting and Charset &  collation
Step 5. Change utf8mb4 to utf8
step 6. Change  collation to utf8_unicode_ci

That’s it.

Laravel Mysql Connection Setting

Manoj Bist

A Passionate Web Developer/Designer With over 6 years of experience in the industry, Manoj Bist is a seasoned professional who combines technical expertise with a down-to-earth demeanor. As a lover of both technology and design, he thrives on creating seamless digital experiences that captivate and inspire.

Leave a Reply

Your email address will not be published. Required fields are marked *