使用 Symfony2 连接 SQL Server 2012
Connect SQL Server 2012 with Symfony2
我想将我的项目 Symfony2 与 SQL 服务器连接,因此我从 link 下载了 SQL 服务器的 Microsoft PHP 驱动程序:https://www.microsoft.com/en-za/download/details.aspx?id=20098
然后我将它提取到 wamp\bin\apache\Apache2.4.4\bin
中并重新启动了 wamp 服务器。
但是当我想从我的 symfony 项目创建我的数据库和表时,我得到了这个错误:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user
'PC-RAMI\rami'@'localhost' (using password: YES)
这是我的 parameters.yml
文件:
parameters:
database_driver: pdo_sqlsrv
database_host: 127.0.0.1
database_port: null
database_name: test
database_user: PC-RAMI\rami
database_password: "password of my PC"
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: a5142e8af29ca527a8d9f3a6993ba894c4bf5ed9
this is the authentication interface of sql server
SQL 服务器使用 two methods for login.
- SQL 服务器身份验证 - 您必须提供用户名和密码(与 MySQL 等相同)。如果你想使用它,你必须配置你的 SQL 服务器进行混合验证。默认用户是 sa.
- Windows 身份验证 - 您想要使用某些 local/domain Windows 帐户的凭据。
您正在尝试使用第二种方法(我从您的屏幕截图中推测)。 解决方案是将用户名和密码设置为空(~ 在 YAML 中)。
database_user: ~
database_password: ~
原因在于 sqlsrv 扩展。 If you provide username and password it always tries to connect by SQL Server Authentication instead of Windows Authentication。但是,PHP 将使用什么作为凭据?它从进程本身获取凭据。可能,您将不得不 运行 Apache2 在目标凭据下。
如果您的 SQL 服务器配置为混合模式。您还可以 create new database 用户帐户(不是来自任何 Windows 帐户)并使用标准 username/password 方法。
我想将我的项目 Symfony2 与 SQL 服务器连接,因此我从 link 下载了 SQL 服务器的 Microsoft PHP 驱动程序:https://www.microsoft.com/en-za/download/details.aspx?id=20098
然后我将它提取到 wamp\bin\apache\Apache2.4.4\bin
中并重新启动了 wamp 服务器。
但是当我想从我的 symfony 项目创建我的数据库和表时,我得到了这个错误:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'PC-RAMI\rami'@'localhost' (using password: YES)
这是我的 parameters.yml
文件:
parameters:
database_driver: pdo_sqlsrv
database_host: 127.0.0.1
database_port: null
database_name: test
database_user: PC-RAMI\rami
database_password: "password of my PC"
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: a5142e8af29ca527a8d9f3a6993ba894c4bf5ed9
this is the authentication interface of sql server
SQL 服务器使用 two methods for login.
- SQL 服务器身份验证 - 您必须提供用户名和密码(与 MySQL 等相同)。如果你想使用它,你必须配置你的 SQL 服务器进行混合验证。默认用户是 sa.
- Windows 身份验证 - 您想要使用某些 local/domain Windows 帐户的凭据。
您正在尝试使用第二种方法(我从您的屏幕截图中推测)。 解决方案是将用户名和密码设置为空(~ 在 YAML 中)。
database_user: ~
database_password: ~
原因在于 sqlsrv 扩展。 If you provide username and password it always tries to connect by SQL Server Authentication instead of Windows Authentication。但是,PHP 将使用什么作为凭据?它从进程本身获取凭据。可能,您将不得不 运行 Apache2 在目标凭据下。
如果您的 SQL 服务器配置为混合模式。您还可以 create new database 用户帐户(不是来自任何 Windows 帐户)并使用标准 username/password 方法。