<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>login failed - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/login-failed/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Sun, 09 Apr 2023 08:23:36 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>login failed - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix Error 18452: Login failed. The login is from an untrusted domain</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Tue, 03 Apr 2018 15:20:47 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2058</guid>

					<description><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below: Error: 18452, Severity: 14, State: 1. Login failed. The login is from an untrusted domain and cannot be used with&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Recently a user has reported error 18452 while connecting to database server. Full description of this error is given below:</p>
<p><span style="color: #ff0000;"><em>Error: 18452, Severity: 14, State: 1.</em></span><br />
<span style="color: #ff0000;"><em>Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.</em></span></p>
<p>You can see the screenshot of the error 18452 in below image.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-2068" src="http://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg" alt="error 18452" width="838" height="124" srcset="https://techyaz.com/wp-content/uploads/2018/04/1-errormin-1024x152.jpg 1024w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-300x45.jpg 300w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin-768x114.jpg 768w, https://techyaz.com/wp-content/uploads/2018/04/1-errormin.jpg 1118w" sizes="(max-width: 838px) 100vw, 838px" /></p>
<h3><span style="color: #333399;">Error 18452 – Root Cause</span></h3>
<p>Reason behind error 18452 is because of wrong security authentication mode configuration. SQL Server is set to accept only windows logins to connect to database instance.</p>
<p>As we know SQL Server uses two authentication modes to accept database connections. One is <em>Windows Authentication mode</em> and another one is <em>SQL Server and Windows Authentication mode</em>. We also call it <em>Mixed Authentication mode</em>.</p>
<p>Sometimes, SQL Server authentication mode is set to <em>SQL Server and Windows Authentication mode</em> to accept SQL as well as windows connections but still you will face this issue. That might be because you try to connect to a server that has <a href="http://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">Always on Availability Group</a> configuration or database mirroring configuration.</p>
<p>Suppose you have AOAG configuration and you are connecting to database using primary replica name not listener name using a login for which default database is set as availability database. If failover got happen during your activity or you are connecting to secondary replica using a login for which default database is set as availability database then also you will get this error 18452 along with some SSPI context error that I have given below.</p>
<p><span style="color: #ff0000;"><em>Error: 17806, Severity: 20, State: 14.</em></span><br />
<span style="color: #ff0000;"><em>SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext failed. The Windows error code indicates the cause of failure. The logon attempt failed  </em></span></p>
<p>SSPI handshake errors comes because of Kerberos failure, which would most likely be related to non-existent SPN or bad SPN for SQL Server.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this issue first we need to check the authentication mode set for your SQL Server Instance. If your SQL Server instance is running with windows authentication mode then you must change it to Mixed mode so that windows and SQL both type of logins can be authenticated.</p>
<p>To check the configured authentication mode for your SQL Server Instance, we need to launch SQL Server Instance property window. Right click at the instance node and click at the properties option as shown in below screenshot.</p>
<p><img decoding="async" class="alignnone size-full wp-image-2059" src="http://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg" alt="Launch SQL Server Instance Property Window" width="319" height="525" srcset="https://techyaz.com/wp-content/uploads/2018/04/2-error-min.jpg 319w, https://techyaz.com/wp-content/uploads/2018/04/2-error-min-182x300.jpg 182w" sizes="(max-width: 319px) 100vw, 319px" /></p>
<p>Once you will click at <strong>Properties</strong> option, you will be getting below SQL Server instance property window. Click at <strong>Security</strong> option from left side pane. You can see current <strong>Server Authentication</strong> configuration is set to <strong><em>Windows Authentication mode</em></strong> in below screenshot.</p>
<p><img decoding="async" class="alignnone wp-image-2060" src="http://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="573" srcset="https://techyaz.com/wp-content/uploads/2018/04/3-error-min.jpg 703w, https://techyaz.com/wp-content/uploads/2018/04/3-error-min-300x269.jpg 300w" sizes="(max-width: 638px) 100vw, 638px" /></p>
<p>Now we will change it to <strong><em>SQL Server and Windows Authentication mode</em></strong>. Select the radio button for <em>SQL Server and Windows Authentication mode</em> option and click ok button to proceed. You can see that I have selected above mode to apply the changes.</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2061" src="http://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg" alt="SQL Server Instance Property Window" width="638" height="578" srcset="https://techyaz.com/wp-content/uploads/2018/04/4-error-min.jpg 702w, https://techyaz.com/wp-content/uploads/2018/04/4-error-min-300x272.jpg 300w" sizes="auto, (max-width: 638px) 100vw, 638px" /></p>
<p>Restart SQL Server services to apply the changes.</p>
<p>If your SQL Server Instance is already set with <em>SQL Server and Windows Authentication mode</em> then you should fix this issue in separate way. As I described above that one of the probable reason to get this error 18452 is because you might use AOAG replica server name to connect to the database with the login for which default database is set as the AOAG availability database.</p>
<p>If failover will happen then you would not be able to access the database because it will become secondary. Error 18452 will be generated along with SSPI handshake errors because same database is set as default database for your login that has become inaccessible now because of acting secondary database in AOAG. Failover will not happen for you because you are using replica server name to make database connection.</p>
<p>Possible solution to fix this issue is failback the AOAG to your earlier primary replica or you should use AOAG Listener name to make database connection. Also, to avoid this error during failover you should set default database for your login to master rather than availability database.</p>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><em><strong><span style="color: #800000;">Read More:</span></strong></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/" target="_blank" rel="noopener">Fix Error 18456: Login failed for user &#8220;User_Name&#8221;</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/" target="_blank" rel="noopener">Fix Error 4064: Cannot open user default database. Login failed</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-53-not-open-connection-sql-server/" target="_blank" rel="noopener">Error 53: Could not open a connection on SQL Server</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/alwayson/fix-aoag-listener-error-19471-kerberos-status-showing-handle-invalid/" target="_blank" rel="noopener">AOAG Listener Error 19471: The handle is Invalid</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/">Fix Error 18452: Login failed. The login is from an untrusted domain</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 18456: Login failed for user &#8216;User_Name&#8217;.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/#comments</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Sun, 24 Dec 2017 07:42:29 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[Connection Issue]]></category>
		<category><![CDATA[connectivity Issue]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[SQL Server Connectivity Issue]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1377</guid>

					<description><![CDATA[<p>Yesterday, a developer has reported an SQL Server error 18456 Login failed for user ‘username’. (Microsoft SQL Server, Error: 18456) on one of the SQL Server instance that are running in lower life cycle. The details about SQL Server error&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/">Fix SQL Server Error 18456: Login failed for user &#8216;User_Name&#8217;.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Yesterday, a developer has reported an SQL Server error 18456 <strong><em>Login failed for user ‘username’. (Microsoft SQL Server, Error: 18456)</em></strong> on one of the SQL Server instance that are running in lower life cycle. The details about SQL Server error 18456 are given below with the screenshot.</p>
<p><em><span style="color: #ff0000;">Cannot Connect to ‘SERVERNAME’.</span></em><br />
<em><span style="color: #ff0000;"> Login failed for user ‘username’. (Microsoft SQL Server, Error: 18456)</span></em></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1379" src="http://techyaz.com/wp-content/uploads/2017/12/error-18456.png" alt="error 18456" width="626" height="321" srcset="https://techyaz.com/wp-content/uploads/2017/12/error-18456.png 626w, https://techyaz.com/wp-content/uploads/2017/12/error-18456-300x154.png 300w" sizes="auto, (max-width: 626px) 100vw, 626px" /></p>
<h3><span style="color: #333399;"><strong>SQL Server Error 18456 &#8211; </strong></span><span style="color: #333399;"><strong>Login failed  </strong></span></h3>
<p>Initially, I thought <em>login failed</em> SQL <em>error 18456 </em>was reported because user might have entered wrong password, but when I tried it with correct password, it displayed same error again. Read this article to fix this error.</p>
<p>When I received same MSSQL error 18456 even after entering correct login id and password then we have decided to check the server authentication mode configured for this instance. Here we got the answer because this SQL Server instance was configured to run in only Windows Authentication mode, that is why SQL Server database engine was not allowing us to login using SQL Server login that comes in to Mixed authentication mode.</p>
<p>As we know there are two types of authentication mode in SQL Server.</p>
<ol>
<li>Windows Authentication Mode</li>
<li>SQL Server and Windows Authentication Mode (Mixed Authentication Mode)</li>
</ol>
<p>Only windows login accounts can connect to SQL Server if your instance is configured in Windows Authentication mode but when Mixed Authentication mode is configured you can connect using windows and SQL Server logins both way.</p>
<h3><span style="color: #333399;"><strong>Solution</strong></span></h3>
<p>So, to fix this SQL Server error 18456 ( <em>Login failed error 18456 ),</em> we have two options:</p>
<ol>
<li>Either Change Server Authentication mode of this SQL Server Instance to Mixed mode (<strong>SQL Server and Windows Authentication Mode</strong>)</li>
<li>Or, <strong>always use windows login</strong> or Domain login account to connect to SQL Server Instance.</li>
</ol>
<p><em><strong>You can also read the below articles which is a comprehensive guide to fix this error 18456:</strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/how-to-fix-sql-server-error-18456-a-comprehensive-guide/" target="_blank" rel="noopener">How to Fix SQL Server Error 18456: A Comprehensive Guide</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/failed-to-open-the-explicitly-specified-database/" target="_blank" rel="noopener">Fix SQL Error 18456: failed to open the explicitly specified database</a></strong></li>
</ul>
<p>Now, let&#8217;s come back to this specific issue. Here, we have decided to change the Server Authentication mode from Windows Authentication to Mixed mode authentication. Below are the steps:</p>
<ol>
<li>Right click on <strong>SQL Server Instance</strong> name in SSMS and choose <strong>properties</strong>.</li>
<li>Select <strong>Security</strong> from left side pane.</li>
<li>You can see Server Authentication mode is set to <strong>Windows Authentication</strong> mode in below screenshot.<br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1380" src="http://techyaz.com/wp-content/uploads/2017/12/Authentication-Mode.jpg" alt="Set Authentication Mode to Mixed mode" width="711" height="635" srcset="https://techyaz.com/wp-content/uploads/2017/12/Authentication-Mode.jpg 711w, https://techyaz.com/wp-content/uploads/2017/12/Authentication-Mode-300x268.jpg 300w" sizes="auto, (max-width: 711px) 100vw, 711px" /></li>
<li>Change this to <strong>SQL Server and Windows Authentication</strong> mode that is second option in above screenshot and click on <strong>OK </strong>button.</li>
<li><strong>Restart SQL Server</strong> and <strong>SQL Server Agent</strong> <strong>services</strong> to apply the changes to database engine.</li>
<li>Now you would be able to login to your SQL Server Instance using SQL logins as well.</li>
</ol>
<p>Here, i have shown you how to fix a SQL Server error 18456 by changing its authentication mode. Read more articles in related section given below.</p>
<p><em><strong><span style="color: #800000;">Related Articles</span></strong></em></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener noreferrer">Fix Error 15170: Login owns one or more Agent Jobs</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/" target="_blank" rel="noopener noreferrer">Fix Login failed Error 4064: Cannot open user default database</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-sql-network-interfaces-error-28-server-doesnt-support-requested-protocol/" target="_blank" rel="noopener noreferrer">How to fix error 28 &#8211; Server doesn&#8217;t support requested protocol</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-18452-login-failed-login-from-untrusted-domain/" target="_blank" rel="noopener noreferrer">Fix Error 18452: Login Failed</a></strong></li>
</ul>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/">Fix SQL Server Error 18456: Login failed for user &#8216;User_Name&#8217;.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/login-failed-user_name-microsoft-sql-server-error-18456/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Fix SQL Server Error 4064: Cannot open user default database. Login failed.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Wed, 06 Dec 2017 07:12:27 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[login failed]]></category>
		<category><![CDATA[logins]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1285</guid>

					<description><![CDATA[<p>Today, I got Microsoft SQL Server error 4064 while I was trying to connect to my SQL Server Instance using my login id techyaz. Read this article to fix this SQL Server error 4064. The error text of this error&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/">Fix SQL Server Error 4064: Cannot open user default database. Login failed.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, I got Microsoft SQL Server error 4064 while I was trying to connect to my SQL Server Instance using my login id techyaz. Read this article to fix this SQL Server error 4064. The error text of this error is &#8220;<em>Cannot open user default database. Login failed.&#8221;</em> This solution is apply to both SQL logins as well as windows logins. The error details are given below:</p>
<div><em><span style="color: #ff0000;">Cannot open user default database. Login failed.</span></em><br />
<em><span style="color: #ff0000;"> Login failed for user “techyaz”. (Microsoft SQL Server, Error: 4064)</span></em></div>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15170/" target="_blank" rel="noopener">Fix 15170: Logins owns one or more Agent Jobs</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15434-not-drop-login-user-currently-logged/" target="_blank" rel="noopener">How to fix error 15434: Could not drop login as the user is currently logged in</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-the-error-15174/" target="_blank" rel="noopener">Error Code 15174: Login &#8216;xxx\yyy&#8217; Owns one or more databases(s). Change the owner of database(s) before dropping the login.</a></strong></li>
</ul>
<h3><span style="color: #333399;">Microsoft SQL Server Error 4064</span></h3>
<p>SQL Server Error 4064 generates because the default database set for your login has been dropped or becomes inaccessible by any reason. Whenever we create any SQL Server or windows login, we mention a default database. If you don’t mention any database during login creation then SQL Server set default database as master database.</p>
<p>You might also get this error on secondary replica of <a href="https://techyaz.com/sql-server/alwayson-availability-group/" target="_blank" rel="noopener">AlwaysON Availability Group</a> because that database on secondary replica remains into inaccessible mode. So, don&#8217;t do any changes if you are getting this error in AOAG environment. You just need to connect to the primary replica because it is designed to keep secondary replica database into inaccessible mode.</p>
<p>Here, we had a database named “TechyazDB” that was set as default database for my login <strong>techyaz</strong>. This database was dropped by someone and when I tried to connect to SQL Server, it gave me below Microsoft SQL Server error 4064 because database was not there on SQL Server instance. Below is the screenshot of Microsoft SQL Server error 4064 that is clearly saying &#8220;<em>Cannot open user default database. Login failed.&#8221;</em></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1287 size-full" src="http://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min.jpg" alt="error 4064" width="633" height="347" srcset="https://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min.jpg 633w, https://techyaz.com/wp-content/uploads/2017/12/1-error-4064-min-300x164.jpg 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /></p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>There are two solutions to fix this issue. Either make your database online by restoring it or by anyway or change the default database of this login to master or any other database that is online on the instance. As you cannot bring your database online because you can’t connect to the instance so your first option is to connect to the instance.</p>
<p>If you have other DBAs or sysadmin accounts, you can connect using those accounts to SQL Server and change the default database for your login to master and then you can make database connection.</p>
<p>Let’s consider only you are the admin on this instance so how will you fix it. Follow below steps:</p>
<p>Launch <strong>SSMS</strong> and click on connect to database engine. Enter <strong>server name</strong> and <strong>login details</strong> for which you are facing issue.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1288" src="http://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min.jpg" alt="connect to database engine" width="442" height="334" srcset="https://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min.jpg 442w, https://techyaz.com/wp-content/uploads/2017/12/2-connect-using-techyaz-min-300x227.jpg 300w" sizes="auto, (max-width: 442px) 100vw, 442px" /></p>
<p>Now click on <strong>Options</strong> tab of above image. You will get below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1289" src="http://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min.jpg" alt="click on options tab of connect database window" width="434" height="515" srcset="https://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min.jpg 434w, https://techyaz.com/wp-content/uploads/2017/12/3-connect-using-techyaz-options-tab-min-253x300.jpg 253w" sizes="auto, (max-width: 434px) 100vw, 434px" /></p>
<p>You can see <strong>Connect to Database</strong> option is set to default database that was <strong>TechyazDB</strong> for this login. Now we need to change this default to any accessible database. It will not allow you to select from drop down. If you will browse the database it will give you same error. You need to enter or type the database name. I typed as master database as shown in below image.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1290" src="http://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min.jpg" alt="change default database in connection property" width="440" height="512" srcset="https://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min.jpg 440w, https://techyaz.com/wp-content/uploads/2017/12/4-change-database-to-master-min-258x300.jpg 258w" sizes="auto, (max-width: 440px) 100vw, 440px" /></p>
<p>Now click on <strong>connect</strong> button to establish the database connection. This time you can connect to your SQL Server instance.</p>
<p>Now, it’s your wish whether you want to bring your database online first or you want to change the default database of your login. Generally, if database has been dropped as a planned activity then you need to change the default database of your login. Read below section to know how to change default database of your login.</p>
<h5><span style="color: #333399;"><strong>Change default database of Login Name</strong></span></h5>
<p>There are two options to change the default database set to any login. One is by using T-SQL code and another is by using GUI. Let’s start with <strong>GUI method</strong>.</p>
<p>As you have connected to your SQL Server Instance. Expand <strong>Security</strong> Folder followed by <strong>Logins</strong> folder. Now <strong>double click</strong> on your login name or right click on login and choose <strong>properties</strong> tab. You will get below property window.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1291" src="http://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min.jpg" alt="login property" width="709" height="631" srcset="https://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min.jpg 709w, https://techyaz.com/wp-content/uploads/2017/12/5-change-default-database-to-master-min-300x267.jpg 300w" sizes="auto, (max-width: 709px) 100vw, 709px" /></p>
<p>You can see <strong>default database is showing as blank</strong>. This was the main issue because your database has dropped from the instance. Now change it to <strong>master</strong> database and click on <strong>OK</strong> button to proceed.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1293" src="http://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min.jpg" alt="change default database in login property window" width="703" height="631" srcset="https://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min.jpg 703w, https://techyaz.com/wp-content/uploads/2017/12/6-change-default-database-to-master-in-login-techyaz-min-300x269.jpg 300w" sizes="auto, (max-width: 703px) 100vw, 703px" /></p>
<p><strong>Second method</strong> is T-SQL method. Run below ALTER command to set the default database of your login.</p>
<pre><span style="color: #0000ff;"><strong><span style="color: #008000;">--Change techyaz with your login name.</span>
ALTER LOGIN [techyaz] WITH DEFAULT_DATABASE = master
</strong></span></pre>
<p>Below is the screenshot of this command.</p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-1294 size-full" src="http://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min.jpg" alt="T-SQL code to set the default database for a login" width="454" height="143" srcset="https://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min.jpg 454w, https://techyaz.com/wp-content/uploads/2017/12/7-change-default-database-to-master-in-login-techyaz-t-sql-min-300x94.jpg 300w" sizes="auto, (max-width: 454px) 100vw, 454px" /></p>
<p><em><strong><span style="color: #800000;">Related Articles:</span></strong></em></p>
<ul>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15173/" target="_blank" rel="noopener">Fix Error 15173: Revoke the permission(s) before dropping the login</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/fix-error-15141-server-principal-owns-one-endpoints-cannot-dropped/" target="_blank" rel="noopener">How to fix error 15141: The Server Principal owns one or more endpoints.</a></strong></li>
<li><strong><a href="https://techyaz.com/sql-server/troubleshooting/fix-error-15138-error-3729/" target="_blank" rel="noopener">How to fix error 15138 and Error 3729</a></strong></li>
</ul>
<p>Here, I have explained step by step solution to fix <em>SQL Server error 4064: Cannot open user default database.</em> I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/">Fix SQL Server Error 4064: Cannot open user default database. Login failed.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-4064-cannot-open-user-default-database-login-failed/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
