作者:帝姬 | 来源:互联网 | 2023-10-10 16:51
我在digitalocean中部署了php laravel项目(版本5.8)。我将远程SQL Server用于数据库。我可以通过SQL SERVER MANAGEMENT连接到远程SQL Server,但是当我在laravel中使用时,出现此错误
"message": "SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (192.168.x.xxxx:1433) (severity 9) (SQL: select top 1 * from [users] where [email] = )",
这是我的.env设置
DB_COnNECTION=sqlsrv
DB_HOST=192.168.0.xxx
DB_PORT=1433
DB_DATABASE=xxxx
DB_username=xxx
DB_PASSWORD=xxxx
return [
'default' => env('DB_CONNECTION','sqlsrv'),'connections' => [
'sqlsrv' => [
'driver' => 'sqlsrv','host' => env('DB_HOST','192.168.x.xxx'),'port' => env('DB_PORT','1433'),'database' => env('DB_DATABASE','xxx'),'username' => env('DB_username','password' => env('DB_PASSWORD','xxxx'),'charset' => 'utf8','prefix' => '',],'migrations' => 'migrations','redis' => [
'client' => 'predis','default' => [
'host' => env('REDIS_HOST','127.0.0.1'),'password' => env('REDIS_PASSWORD',null),'port' => env('REDIS_PORT',6379),'database' => 0,];
尝试更改
'驱动程序'=>'sqlsrv',
到
'驱动程序'=>'mysql',