Wrong COM_STMT_PREPARE response size. Received 7. LARAVEL ERROR

◇◆丶佛笑我妖孽 提交于 2019-12-24 08:16:03

问题


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

  1. Server: MariaDB
  2. Server version: 10.1.20-MariaDB - MariaDB Server
  3. PHP 5.6

I could not find any solution. Any help would be greatly appreciated.


回答1:


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,]
],



回答2:


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:

  1. /bootstrap/cache/config.php
  2. /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.




回答3:


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



来源:https://stackoverflow.com/questions/43953626/wrong-com-stmt-prepare-response-size-received-7-laravel-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!