无法使用Laravel 5连接到数据库 [英] Can't connect to database with laravel 5

查看:68
本文介绍了无法使用Laravel 5连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用laravel 5连接到我的mssql数据库,但是它不起作用.我尝试连接不同的mssql数据库,所以这不是防火墙问题.我的凭据也是正确的.我在Google上发现您需要SQL Server Native Client 11.0,并且我已经安装了它.

I'm trying to connect to my mssql database with laravel 5 but it's not working. I've tried to connect with different mssql databases so it's not a firewall issue. Also my credentials are correct. I found on google that you need SQL Server Native Client 11.0 and I've already installed that.

这是我在config/database.php中的连接数组:

This is my connection array in config/database.php:

'sqlsrv' => [
            'driver'   => 'sqlsrv',
            'host'     => env('nvt'),
            'database' => env('nvt'),
            'username' => env('nvt'),
            'password' => env('nvt'),
            'charset'  => 'utf8',
            'prefix'   => '',
        ],

我将默认值设置为"sqlsrv":

And I've set the default to "sqlsrv" :

'default' => env('sqlsrv','sqlsrv'),

但是当我尝试创建表时,会收到错误消息:

But when I'm trying to create a table I receive the error:

Connector.php第50行中的PDOException:找不到驱动程序

PDOException in Connector.php line 50: could not find driver

可能出什么问题了?

我从这里安装了sqlsrv的pdo: http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx

I've installed pdo for sqlsrv from here: http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx

然后将其添加到我的php.ini文件中:extension = \ Installaties \ php_pdo_sqlsrv_53_nts.dll

And I added it to my php.ini file: extension=\Installaties\php_pdo_sqlsrv_53_nts.dll

但是仍然收到错误消息吗?

But stil I receive the error?

推荐答案

尝试删除eve()方法,我的意思是使用以下方法

Try to remove the eve() method, i mean use the following method

'sqlsrv' => [
        'driver'   => 'sqlsrv',
        'host'     => 'nvt',
        'database' => 'nvt',
        'username' => 'nvt',
        'password' => 'nvt',
        'charset'  => 'utf8',
        'prefix'   => '',
    ],

这篇关于无法使用Laravel 5连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆