Error en php artisan migrate --seed estoy usando MySql
Closed this issue · 5 comments
me muestra el siguiente error:
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
))
at /home/frisly/larapro/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
/home/frisly/larapro/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
2 PDOStatement::execute()
/home/frisly/larapro/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
Please use the argument -v to see more details.
This is a well known Laravel problem: https://laravel-news.com/laravel-5-4-key-too-long-error
But they key length was set in this demo project, so I guess you're using the Vanilo framework in an application and you have to add:
Schema::defaultStringLength(191);
in your AppServiceProvider::boot()
method.
Ps. please use English.
Thanks, true solved now I get this error, but I'm not using MariaDB
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'json not null, custom_properties
js
on not null, responsive_images
json not n' at line 1 (SQL: create table media
(id
int unsigned not null auto_
increment primary key, model_type
varchar(191) not null, model_id
bigint unsigned not null, collection_name
v
archar(191) not null, name
varchar(191) not null, file_name
varchar(191) not null, mime_type
varchar(191) nul
l, disk
varchar(191) not null, size
int unsigned not null, manipulations
json not null, custom_properties
j
son not null, responsive_images
json not null, order_column
int unsigned null, created_at
timestamp null, up dated_at
timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
In Connection.php line 452:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near 'json not null, custom_properties
js
on not null, responsive_images
json not n' at line 1
The doc says:
Database engine: MySQL 5.7 or higher, MariaDB 10.2.7 or higher or PostgreSQL is required
You can check your db engine version with this command:
mysql -V
(MySQL and MariaDB)
or
psql - V
(Postgres)
Has the issue been resolved?
Feel free to reopen if the issue persists.