【发布时间】:2018-09-17 01:25:30
【问题描述】:
我正在尝试从 Laravel vagrant homestead 连接我的本地/主机 SQL Server。我整天都在谷歌搜索,试图连接主机的数据库,安装不同的 PHP 包,但到目前为止还没有运气。我想此时我会删除 PHP 并尝试使用 sqlcmd 在宅基地内建立连接。
所以,我在宅基地安装了sqlcmd,并尝试执行以下命令连接到主机的数据库。
sqlcmd -S 10.0.2.2,1433 -U sa -P 'password' -Q "sp_databases"
但是,我收到以下错误:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection because an error was encountered during handshakes before login. Common causes include client attempting to connect to an unsupported version of SQL Server, server too busy to accept new connections or a resource limitation (memory or maximum allowed connections) on the server..
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection due to prelogin failure.
但是,如果我在主机上使用sqlcmd 并执行以下命令,我就可以访问数据库。
sqlcmd -S LAPTOP-ACQES\MSSQL2017 -U sa -P Asdf1234 -Q "sp_databases"
在我的 Homestead.yaml 中,我设置了端口转发:
ports:
- send: 1433
to: 1433
【问题讨论】:
标签: sql-server laravel vagrant homestead