登录SQL Server时出错 [英] Error in login to SQL Server

查看:110
本文介绍了登录SQL Server时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想连接到SQL Server 2008时,出现以下消息:

When I want to connect to SQL Server 2008, I get this message:

无法连接到服务器.
附加信息:无法打开用户默认数据库.登录失败.用户"sa"的登录失败. (Microsoft SQL Server.错误:4064)

Cannot connect to server.
Additional Information: Cannot open user default database. Login failed. Login fail for user 'sa'. (Microsoft SQL Server. Error:4064)

如何解决此错误?

推荐答案

当某些数据库用户默认删除的数据库时,会发生此错误(Microsoft SQL Server.Error:4064).

This error (Microsoft SQL Server.Error:4064) occurs when the database which is dropped is default for some database user.

当用户尝试登录并删除其默认数据库时,将显示错误.

When the user tries to login and their default database is dropped the error shows up.

无法打开用户默认数据库.登录失败.用户登录失败 '用户名'. (Microsoft SQL Server,错误:4064)

Cannot open user default database. Login failed. Login failed for user ‘UserName’. (Microsoft SQL Server, Error: 4064)

给出了解决此问题的方法

The way to resolve this is given here, summarized below.

登录的解决方案是:

  1. 连接到服务器对话框中,单击选项
  2. 连接到数据库的值更改为服务器上任何有效的数据库
  1. From the Connect to Server dialog, click Options
  2. Change value of Connect to database: to any valid database on the server

修复服务器的永久性解决方案是像这样运行SQL:

The permanent solution to fix the server is to run SQL like:

ALTER LOGIN [test] WITH DEFAULT_DATABASE = master
GO

这篇关于登录SQL Server时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆