utf8mb4
which includes support for storing emojis. This only affects new applications, and as long as you’re running MySQL V5.7.7 and later, you don’t need to do anything.For users running MariaDB or older versions of MySQL, you may encounter this error when trying to run the migration:
[Illuminate \ Database \ QueryException] SQLSTATE[42000]: Syntax Error or Access Restriction: 1071 Specified key was too long; Max key length is 767 bytes (SQL: alter table
users
add uniqueusers_email_unique
(
[PDOException]
SQLSTATE [42000] : syntax error or access conflict: 1071 specified key is too long; The maximum key length is 767 bytes
As described in the migration guide, to solve this problem, you simply edit the AppServiceProvider. PHP
file and set the default string length within the boot
method:
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
After that, everything should work normally.
(PS: The exception explicitly indicates that the maximum length is 767 bytes, and utF8MB4 encodes 4 bytes per character, so 767/4 = 191.75, so set the default length of string to 191 characters. I hope it helps.)
Read More:
- Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and co
- IIS “Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long.”
- An error is reported when the laptop is turned on: image failed to verify with * access denied* press any key to continue
- svn Key usage violation in certificate has been detected
- Bad Request – Request Too Long. HTTP Error 400. The size of the request headers is too long
- MySQL failed to add foreign key: SQL 1452 cannot add or update a child row:a foreign key constraint fails
- A simple method of generating secret key by GIT and configuring SSH public key
- Command line is too long. Shorten command line for QuestionnaireApplication or also for Spring Boot
- Idea: error running Name: command line is too long
- Error command line is too long when idea project is started [How to Solve]
- MySQL error code 1217 (ER_ROW_IS_REFERENCED): Cannot delete or update a parent row: a foreign key co
- Solutions to remote or adding SSH key errors
- Error in idea unit test command line is too long
- Mysql error 1452 – Cannot add or update a child row: a foreign key constraint fails
- SSH Login: RSA host key for 192.168.x.x has changed and you have requested strict checking. Host key
- MySql 8.x java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
- Solve the problem of error running xxxapplication command line is too long when compiling and running IntelliJ idea
- 1. Error running ‘application’ occurs when the command line is too long
- Error 0210: stick key 28 is displayed when ThinkPad E40 is turned on
- Idea running error running ‘application’: solution to command line is too long