Skip to content

Instantly share code, notes, and snippets.

@Ahmed-Radi
Created February 29, 2020 14:08
Show Gist options
  • Save Ahmed-Radi/da242bc5b8f8249f65eddf18194a56a7 to your computer and use it in GitHub Desktop.
Save Ahmed-Radi/da242bc5b8f8249f65eddf18194a56a7 to your computer and use it in GitHub Desktop.
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 MariaDB server version for the right syntax to use near 'unsigned not null, created_at timestamp null, updated_at timestamp null) def' at line 1 (SQL: create table categories (cat_id bigint unsigned not null auto_increment primary key, cat_name varchar(255) unsigned not null, created_at timestamp null, updated_at timestamp null) default character set utf8 collate 'utf8_unicode_ci')
at E:\xampp\htdocs\laravel\Laravel\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:
@Ahmed-Radi
Copy link
Author

Ahmed-Radi commented Feb 29, 2020

To solve this problem :
First solution : in this pathway config/database.php

Edit :
55| 'charset' => 'utf8mb4',
56| 'collation' => 'utf8mb4_unicode_ci',

To

55| 'charset' => 'utf8',
56| 'collation' => 'utf8_unicode_ci',

Second Solution : Up date MariaDB

1-Shutdown MySQL in your XAMPP server from Xampp control panel or mysql under Services if it was added.
2-Download the ZIP version of MariaDB (https://downloads.mariadb.org/) - you may download the winx64.zip if you are also switching to x64 variant of mariadb
3-Rename the xampp/mysql folder to mysql_old
4-Unzip or Extract the contents of the MariaDB ZIP file into your XAMPP folder
5-Rename the MariaDB folder, called something like mariadb-10.3.14-winx64, to mysql
6-Rename xampp/mysql/data to data_temp
7-Copy the xampp/mysql_old/data folder to xampp/mysql/
8-Copy the xampp/mysql_old/backup folder to xampp/mysql/
9-Copy the xampp/mysql_old/scripts folder to xampp/mysql/
10-Copy mysql_uninstallservice.bat and mysql_installservice.bat from xampp/mysql_old/ into xampp/mysql/
11-Copy xampp/mysql_old/bin/my.ini into xampp/mysql/bin
12-Edit xampp/mysql/bin/my.ini using a text editor like Notepad
13-Find skip-federated and add a # in front (to the left) of it to comment out the line if it exists
14-Find innodb_additional_mem_pool_size=2 and add a # in front (to the left) of it to comment out the line if it exists
15-Add this skip-grant-tables statement anywhere in xampp/mysql/bin/my.ini file Save and exit the editor
16-Start-up XAMPP
17-Run xampp/mysql/bin/mysqlcheck --repair --all-databases
18-Run xampp/mysql/bin/mysql_upgrade.exe
19-Shutdown and restart MySQL (MariaDB)

The third solution : in this pathway config/database.php

replace this line for mysql:

 'engine' => null,

To

 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',

The fourth solution : in this pathway App/Providers/AppServiceProvider.php

Add this in top :

   use Illuminate\Support\ServiceProvider;
   use Illuminate\Support\Facades\Schema;

Then in boot() Add this Line

   Schema::defaultStringLength(191);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment