SQLSTATE [HY000]:[Microsoft] [用于SQL Server的ODBC驱动程序11] TDS协议错误

时间:2019-04-12 10:19:05

标签: php html laravel

我试图从laravel连接到新的bbdd,但出现标题中出现的错误 我将其放在bbdd(database.php)的配置文件下面,并从控制器中调用它

     'reporting' => [
        'driver' => 'mysql',
        'host' => env('DB_REPORTING_HOST', 'localhost'),
        'port' => env('DB_REPORTING_PORT', '3306'),
        'database' => env('DB_REPORTING_DATABASE', 'reporting'),
        'username' => env('DB_REPORTING_USERNAME', 'paco'),
        'password' => env('DB_REPORTING_PASSWORD', 'qwerty'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
    ],

和通话

    $DB = DB::connection('reporting');
    $DB->table('clients')->get();

1 个答案:

答案 0 :(得分:0)

修复

'reporting' => [
    'driver'     => 'mysql',
    'host' => '127.0.0.1',
    'port' => '3306',
    'database'   =>'reporting',
    'username'   => 'paco',
    'password'   => 'qwerty',
    'charset'    => 'utf8',
    'collation'  => 'utf8_unicode_ci',
    'prefix'     => '',
    'strict'     => false,
],

然后在控制器中

 $dataL = DB::connection('reporting');//->select('select * from leyenda');
 $dataL2 = $dataL->table('familias')->get()