I want to connect an MS-SQL server v11.0.700 using Doctrine. The user I have to use exists on the SQL server as user with “SQL Authentication”.
What I do is:
$modelPath = __DIR__."/../model";
$config = ORMSetup::createAttributeMetadataConfiguration(
paths: array($modelPath),
isDevMode: true,
);
$conn = array(
'driver' => "pdo_sqlsrv",
'host' => "sqlserver1",
'user' => "myUser",
'password' => "fancyPwdHere123",
'dbname' => "testDatabase",
);
$entityManager = EntityManager::create($conn, $config);
The result is is:
PHP Fatal error: Uncaught PDOException: SQLSTATE[28000]:
[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'myUser'.
in E:PHPDoctrine-ORMvendordoctrinedbalsrcDriverPDOSQLSrvDriver.php:42
Stack trace:
#0 E:PHPDoctrine-ORMvendordoctrinedbalsrcDriverPDOSQLSrvDriver.php(42): PDO->__construct()
#1 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(346): DoctrineDBALDriverPDOSQLSrvDriver->connect()
#2 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(1619): DoctrineDBALConnection->connect()
#3 E:PHPDoctrine-ORMvendordoctrinedbalsrcConnection.php(1013): DoctrineDBALConnection->getWrappedConnection()
#4 E:PHPDoctrine-ORMtryIt.php(7): DoctrineDBALConnection->prepare()
#5 {main}
The user name and password is good (double checked). My PHP is 8.1.11, and composer.json content is:
{
"require": {
"doctrine/orm": "^2.11.0",
"doctrine/dbal": "^3.2",
"symfony/yaml": "^5.4",
"symfony/cache": "^5.4"
},
"autoload": {
"psr-0": {"": "src/"}
}
}
Any advice why this happens and how to resolve the login problem? Thanks in advance!