douchuo0730 2013-06-29 03:51
浏览 70
已采纳

使用PHP将本地SQL数据库备份到同一台计算机上

I'm using Wamp to, among other things, run a couple of local PHP sites that use local mySQL dbs in order to organize and keep personal info. None of this touches anything outside my PC. It just works on my local virtual server. However, if something happens to my PC, then everything's gone. If this were online, in an external server, then there's auto backup, but as it is private info, security issues make this impossible, besides impractical.

What I would like is to be able to export my SQL db upon hitting the SAVE button on new info I'm inserting into the db. I would like to save the db into, for example, my Dropbox folder. This way, if anything happens to my PC, I have my dbs secure in my Dropbox.

I've found how to backup dbs onto the same server and obviously I know how to do it manually through phpMyAdmin, but I can't find how to this onto a computer, moreover, the same computer where the local server is being run with the dbs.

Can anyone please help?

  • 写回答

2条回答 默认 最新

  • dongluni0568 2013-11-16 22:40
    关注

    In the end, after much looking into the issue and leaving it, letting it ripen in my mind, I was able to find exactly what I needed by using mysqldump:

    exec('mysqldump --user=XXX --password=XXX --host=localhost DBNAME > outputfile.sql');
    

    Hope it might help someone else out there!

    P.S. Thanks a lot to @hellosheikh for the answer. It did provide very interesting info that might prove handy later on. However, for my exact needs, this second way in the end proved more practical.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度