4060: Cannot open database requested by the login. The login failed(无法打开登录所请求的数据库。登录失败)
SQL Server含义
认证可能成功,但由于无法打开所请求的数据库,连接被拒绝。通常与 18456 一起出现。
原因
数据库不存在、处于 OFFLINE/SINGLE_USER/RESTORING/SUSPECT 状态、登录名在该数据库中没有用户映射,或连接字符串中的默认数据库不可访问。
解决方法
确认数据库存在且处于 ONLINE:SELECT name, state_desc FROM sys.databases。在数据库中为该登录名创建用户并授予权限。检查连接字符串中的 Initial Catalog/Database 值。如果数据库处于 RESTORING/SUSPECT,按照修复/恢复步骤处理。
同一数据库的其他条目
- 1105Could not allocate space for object in database because the filegroup is full(由于文件组已满,无法在数据库中为对象分配空间)
- 208Invalid object name(对象名无效)
- 229The SELECT/EXECUTE permission was denied on the object(拒绝了对对象的 SELECT/EXECUTE 权限)
- 233A connection was successfully established with the server, but then an error occurred (no process is on the other end of the pipe)(已成功与服务器建立连接,但随后发生错误(管道的另一端上无任何进程))
- 823The operating system returned error to SQL Server during a read/write at offset in file (I/O error)(操作系统在文件的偏移量处读/写时向 SQL Server 返回了错误(I/O 错误))
- 824SQL Server detected a logical consistency-based I/O error (page corruption)(SQL Server 检测到基于逻辑一致性的 I/O 错误(页损坏))
- 701There is insufficient system memory in resource pool to run this query(资源池中的系统内存不足,无法运行此查询)