Laravel / MySQL Error: SQLSTATE[HY000]: General error: 1835 Malformed communication packet

for a quick fix just add this

'options' => [PDO::ATTR_EMULATE_PREPARES => true]

to config/database.php in

'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => false,
        'engine' => null,
        'options'   => [PDO::ATTR_EMULATE_PREPARES => true],
    ],

the proper solution is to upgrade your php from 7.2 to 7.4 or downgrade your mariadb

Tags:

Mysql

Php

Laravel