我在共享托管计划中有一个采用 EntityFramework codefirst 方法的 Asp.Net MVC 5 网站。它使用开源 WebbsitePanel用于控制面板及其 SQL Server 面板的功能有些受限。今天想编辑数据库的时候遇到了这个错误:
The transaction log for database 'db_name' is full due to 'LOG_BACKUP'
我四处搜索,发现了很多相关的答案,比如 this和 this或 this但问题是他们建议在数据库上运行查询。我试过运行
db.Database.ExecuteSqlCommand("ALTER DATABASE db_name SET RECOVERY SIMPLE;");
使用 visual studio(在 HomeController
上)但出现以下错误:
System.Data.SqlClient.SqlException: ALTER DATABASE statement not allowed within multi-statement transaction.
我该如何解决我的问题?我应该联系支持团队(这对我的房东来说有点糟糕)还是我可以自己解决这个问题?
最佳答案
除了 Ben 的回答,您还可以根据需要尝试 Below Queries
USE {database-name};
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE {database-name}
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE ({database-file-name}, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE {database-name}
SET RECOVERY FULL;
GO
更新 感谢@cema-sp
要查找数据库文件名,请使用以下查询
select * from sys.database_files;
关于asp.net - 共享主机中的 "The transaction log for database is full due to ' LOG_BACKUP '",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21228688/