mysql从备份部分恢复
由于服务器崩溃,我需要将在特定时间段内创建的一些行从备份(位于我的本地计算机上)恢复到服务器上的实时数据库上。
要选择有问题的行,我计划从备份数据库执行类似的操作:
SELECT *
FROM access AS t1
WHERE AccessId IN (
SELECT AccessId FROM access_completed AS t1
WHERE (TIMEDIFF(CCompleteDateTime, "2011-01-24 02:00:00") < 23 AND TIMEDIFF(CCompleteDateTime, "2011-01-24 02:00:00") > 0)
)
如何将结果行插入实时数据库?
Due to a server crash I need to restore some rows, created within a certain period of time, from the backup (located on my local machine) onto the live db on server.
To select the rows in question I plan to do something like this from the backupdatabase:
SELECT *
FROM access AS t1
WHERE AccessId IN (
SELECT AccessId FROM access_completed AS t1
WHERE (TIMEDIFF(CCompleteDateTime, "2011-01-24 02:00:00") < 23 AND TIMEDIFF(CCompleteDateTime, "2011-01-24 02:00:00") > 0)
)
How do I insert the resulting rows into the live db?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
SELECT ... INTO OUTFILE
< /a> 备份并LOAD DATA INFILE
加载数据。
INTO OUTFILE 将选定的数据转储到本地文件,其格式是 MySQL 可以使用 LOAD DATA INFILE 解析的格式。因此,您只需像这样转储和加载:
将 outfile 复制到其他服务器
在其他服务器上:
它也可以与
FEDERATED
表。这将允许从主服务器查询备份数据库;所以你可以执行INSERT INTO access ... SELECT ... FROM federated_access ...
。You can use
SELECT ... INTO OUTFILE
on the backup andLOAD DATA INFILE
to load data.INTO OUTFILE
dumps the selected data to a local file, in a format that MySQL can parse back usingLOAD DATA INFILE
. So you just have to dump and load like this:Copy outfile to the other server
And on the other server:
It would also work with
FEDERATED
tables. This would allow to query the backup database from the main server; so you could doINSERT INTO access ... SELECT ... FROM federated_access ...
.