無法開啟使用者預設資料庫。登入失敗

Microsoft.SQLServer.2012.Cannot_open_user_default_database._Login_failed_1_5_Rule (Rule)

Knowledge Base article:

摘要

當用戶端連線至 SQL Server 執行個體但未指定資料庫內容時,將會用到為其登入定義的預設資料庫。如果該資料庫因故無法使用,則會出現上述訊息。

注意:如果此登入為一個或多個 Windows 群組中的成員,而這些群組也已定義為 SQL Server 中的登入,則可能會使用其中一個群組的預設資料庫。沒有可靠的方法可預測登入嘗試時將會選擇的預設資料庫。因此,請務必檢查登入帳戶的群組成員資格,然後檢查所有群組的預設資料庫,以確定這些資料庫均可用。

解決方式

您需要確保預設資料庫可用或避免使用此特定資料庫。選項包含:

如需預設資料庫的詳細資訊,請參閱《線上叢書》中的<sp_defaultdb>與 Microsoft 知識庫文件 307864196076

Element properties:

TargetMicrosoft.SQLServer.2012.DBEngine
CategoryEventCollection
EnabledTrue
Event_ID4064
Event Source$Target/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ServiceName$
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
RemotableTrue
Alert Message
無法開啟使用者預設資料庫。登入失敗
{0}
Event LogApplication
CommentMom2012ID='{4FFA6A6A-3E49-468E-8C4A-DF5029908802}';MOM2012GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}

Member Modules:

ID Module Type TypeId RunAs 
_F6DA1507_12AF_11D3_AB21_00A0C98620CE_ DataSource Microsoft.Windows.EventProvider Microsoft.SQLServer.SQLDefaultAccount
GenerateAlert WriteAction System.Health.GenerateAlert Default

Source Code:

<Rule ID="Microsoft.SQLServer.2012.Cannot_open_user_default_database._Login_failed_1_5_Rule" Target="SQL2012Core!Microsoft.SQLServer.2012.DBEngine" Enabled="true" ConfirmDelivery="true" Remotable="true" Comment="Mom2012ID='{4FFA6A6A-3E49-468E-8C4A-DF5029908802}';MOM2012GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}">
<Category>EventCollection</Category>
<DataSources>
<DataSource ID="_F6DA1507_12AF_11D3_AB21_00A0C98620CE_" Comment="{F6DA1507-12AF-11D3-AB21-00A0C98620CE}" TypeID="Windows!Microsoft.Windows.EventProvider" RunAs="SQL!Microsoft.SQLServer.SQLDefaultAccount">
<ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
<LogName>Application</LogName>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>PublisherName</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>$Target/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ServiceName$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>EventDisplayNumber</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>4064</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="GenerateAlert" TypeID="SystemHealth!System.Health.GenerateAlert">
<Priority>1</Priority>
<Severity>2</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.SQLServer.2012.Cannot_open_user_default_database._Login_failed_1_5_Rule.AlertMessage"]$</AlertMessageId>
<AlertParameters>
<AlertParameter1>$Data/EventDescription$</AlertParameter1>
</AlertParameters>
<Suppression>
<SuppressionValue/>
</Suppression>
</WriteAction>
</WriteActions>
</Rule>