I have a blog that is developed using laravel. In my local PC, everything is okay. But when I upload it in live shared hosting server it throws error like below:
ErrorException in MySqlConnector.php line 124:
Wrong COM_STMT_PREPARE response size. Received 7
My server configuration is given below
- Server: MariaDB
- Server version: 10.1.20-MariaDB - MariaDB Server
- PHP 5.6
I could not find any solution. Any help would be greatly appreciated.
I also faced the same problem. My web host provider was 000webhost. Just set this PDO attribute PDO::ATTR_EMULATE_PREPARES
to true in your database config file (config/database.php) and it should work fine.
Eg:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
//.......
'options' => [PDO::ATTR_EMULATE_PREPARES => true,]
],
Inside both
(1) /bootstrap/cache/config.php
(2) /config/database.php
For your particular database-server driver you need to add:
'options' => [PDO::ATTR_EMULATE_PREPARES => true]
For example:
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
//.....
'options' => [PDO::ATTR_EMULATE_PREPARES => true]
but please not you have to add it in both files:
- /bootstrap/cache/config.php
- /config/database.php
because when I added it just inside /config/database.php I kept getting the same error, so after hours of googling around, I realized it is because this /bootstrap/cache/config.php is sort of a cache file made from Laravel .env file and /config/database.php and other files, and this cache file seems to be made only once when you set the API_KEY thing inside .env file with php artisan key:generate.
After researching everywhere I came to conclusion that the problem is in the database engine of the shared hosting, maybe a permission or something, so the solution I found was to create the database in a separate service. I used sql9.freemysqlhosting.net and is working fine so far.
note: This idea above is copied from another person but i tried it, and it works successfully