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条)

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)