Laravel connect to a SQL Server 2008 named instance

前端 未结 2 990
抹茶落季
抹茶落季 2021-02-09 08:23

I am trying to connect an SQL server from an Ubuntu machine, everythings works great except for named instances:

this works

\'data\' =&g         


        
2条回答
  •  长发绾君心
    2021-02-09 08:35

    I finally found a solution, there were two problems :

    • The SQL server wasn't listening on the good default port (my bad)
    • Laravel (PDO ?) doesn't know how to handle (or at least I haven't found how) named instances, I have tried any possible combination (see Question)

    So I finally used a combination of FreeTDS DSN with laravel in order to connect the SQL named instance server.

    The /etc/freetds.conf DSN configuration:

    [NAMED_INSTANCE]
       host = 127.0.0.1
       port = 55021
    

    And in the laravel database adapter:

    'webcmd' => array(
        'driver'   => 'sqlsrv',
        'host'     => 'NAMED_INSTANCE',
        'database' => 'db',
        'username' => 'usr',
        'password' => 'pwd',
        'prefix'   => '',
    ),
    

    And that solved my problem, hope it'll help someone too

提交回复
热议问题