[英]mssql using pdo fail login getting Login failed for user 'dbo'
IN Microsoft SQL server Management Studio when I run 在运行时在Microsoft SQL Server Management Studio中
EXEC sp_helplogins @LoginNamePattern='mmanlapig\martin'
I get this : 我明白了:
LoginName DBName UserName UserOrAlias
1 mmanlapig\martin homis db_owner MemberOf
2 mmanlapig\martin homis dbo User
Then in my code I have : 然后在我的代码中,我有:
define('DBHOST', 'localhost\SQLEXPRESS');
define('DBNAME', 'homis');
define('DBUSER', 'dbo');
define('DBPASS', '');
$dbname = "`" . str_replace("`", "``", DBNAME) . "`";
$dbh1 = new PDO("odbc:Driver={SQL Server};Server=" . DBHOST . ";Database=$dbname;", DBUSER, DBPASS);
When I run this code 当我运行这段代码
Select sp.name as LoginName, sp.type_desc as LoginType,
dp.name as DBUser, dp.type_desc as UserType
from sys.server_principals sp
join sys.database_principals dp on dp.sid = sp.sid
where sp.name = 'mmanlapig\martin';
I get 我懂了
LoginName LoginType DBUser UserType
1 mmanlapig\martin WINDOWS_LOGIN dbo WINDOWS_USER
Tried these steps from here 从这里尝试了这些步骤
The issue was that the server was set to "Windows Authentication Mode" only. 问题是服务器仅设置为“ Windows身份验证模式”。 To fix this I
为了解决这个问题
Still same issues
还是一样的问题
Hope this article helps you: Using PDO's odbc to connect to a MSSQL server instance with Windows Authentication 希望本文对您有所帮助: 使用PDO的odbc通过Windows身份验证连接到MSSQL服务器实例
$conn = new PDO(
'odbc:
Driver=SQL Server;
Server=MyServer\MyInstance;
Database=MyDatabaseName;
Trusted Connection=Yes;'
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.