How to Fix Laravel Database QueryException: SQL Syntax Error

Error message

Illuminate\Database\QueryException

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'base) null, updated_at timestamp(base) null, created_at timestamp(name) null' at line 1 (Connection: mysql, SQL: create table pizzas (id bigint unsigned not null auto_increment primary key, created_at timestamp null, updated_at timestamp null, type varchar(191) not null, created_at timestamp(base) null, updated_at timestamp(base) null, created_at timestamp(name) null, updated_at timestamp(name) null) default character set utf8 collate 'utf8_unicode_ci')

at vendor\laravel\framework\src\Illuminate\Database\Connection.php:813 809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 810▕ ); 811▕ } 812▕ ➜ 813▕ throw new QueryException( 814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 815▕ ); 816▕ } 817▕ }

PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'base) null, updated_at timestamp(base) null, created_at timestamp(name) null' at lineo your MySQL server version for the right syntax t 1")

2 vendor\laravel\framework\src\Illuminate\Database\Connection.php:565 PDO::prepare("create table pizzas (id bigint unsigned not null auto_increment primary key, created_at timestamp null, updated_at timestamp null, type varchar(191) not null, created_atp null, type varchar(191) not null, created_at timestamp(base) null, updated_at timestamp(base) null, created_at timestamp(name) null, updatedtf8 collate 'utf8_unicode_ci'")_at timestamp(name) null) default character set utf8 collate 'utf8_unicode_ci'") 8

solution

1.Open your project directory

2.Search for database.php under config folder

3.change your charset from utf8fm to utf8 under mysql array