--
建立測試資料庫test
create
database
test
onprimary
(name='
test_data.mdf',
filename='
d:/test_data.mdf')
logon
(name='
test_data.ldf',
filename='
d:/test_data.ldf')
--建立測試表
create
table
test.dbo.ta(id
int)
insert
into
test.dbo.ta
select
id from
sysobjects
--建立備份檔案
backup
database
test
todisk='
d:/test.bak
'with
format
--建立乙個ndf檔案
alter
database
test
addfile
(name='
file',
filename='
d:/test.ndf',
size
=1mb)--
關閉mssql服務,然後刪除ndf檔案然後再開啟mssql服務,此時test資料庫被疑置啦!
--恢復資料疑置
--首先備份日誌檔案
backup
logtest
todisk='
d:/test_log.bak
'with
format,no_truncate
--利用檔案組備份檔案恢復被破壞的檔案
restore
database
test
from
disk='
d:/test.bak
'with
norecovery
--恢復日誌檔案
restore
logtest
from
disk='
d:/test_log.bak
'with
recovery --
tips
--如果已經建立ndf檔案的話那麼恢復日誌檔案的話用下面的這句話
--只不過將with recovery-->with replace
restore
logtest
from
disk='
d:/test_log.bak
'with
replace
Mysql通過binlog恢復資料庫
需要開啟binlog日誌 編輯開啟mysql配置檔案my.ini,在 mysqld 區塊設定 新增 log bin mysql bin 然後重啟mysql服務 檢視二進位制日誌是否已開啟 mysql show variables like log log bin的值為no表示已開啟binlog日誌 ...
binlog日誌檔案 恢復資料庫
檢視資料庫是否開啟binlog日誌 show variables like log bin 如果 log bin off 則在my.ini檔案加入如下命令 路徑為自己mysql下位置所在 d wamp bin mariadb mariadb10.4.10 bin log 自己所建立檔案 mysql ...
通過frm和ibd恢復資料庫
新建空的資料庫,匯入上述表結構 刪除對應的表空間,將表對應的ibd檔案複製到資料目錄下 重新插入表空間 mysql 備份var目錄,初始化資料庫mysqld initialize insecure通過mysqlfrm可以從frm中獲取表結構 新建空的資料庫,匯入上述表結構 刪除對應的表空間,將表對應...