简体   繁体   English

从Wamp服务器上运行的localhost备份mySQL数据库

[英]Backup mySQL databases from localhost running on Wamp server

For a while now I've been trying to automate the backup of some databases I've got running in my localhost. 有一段时间我一直在尝试自动备份我在本地主机上运行的一些数据库。 I have a couple of personal apps running on my PC and I would like to back their db's continuously so as not to lose any of that info (because it's not online, so there's always the issue with my PC breaking down or a virus wiping everything out, etc.) 我在我的电脑上运行了几个个人应用程序,我想连续支持他们的数据库,以免丢失任何信息(因为它不在线,因此我的电脑出现故障或病毒擦拭一切都存在问题出去等)

So I've been looking for a way to do this for some time now. 所以我一直在寻找一种方法来做这件事。 I've continuously hit walls due to the fact that this is a local virtual server. 由于这是一个本地虚拟服务器,我不断打击墙壁。 But finally I seem to have found a way to do it. 但最后我似乎找到了一种方法。

It works perfectly at the output end. 它在输出端完美运行。 I mean, I wanted something that would output the dbs to my Dropbox, for instance, and this works... It outputs a file, alright, but the file is empty, which can only mean it's not able to retrieve the actual data. 我的意思是,我想要一些可以将dbs输出到我的Dropbox的东西,例如,这可行...它输出一个文件,好吧,但文件是空的,这只能意味着它无法检索实际数据。 I've tried several things, including setting the exact path of the SQL data within my Wamp folder, but to no avail. 我已经尝试了几件事,包括在我的Wamp文件夹中设置SQL数据的确切路径,但无济于事。

I'm rather stuck here. 我宁愿被困在这里。 Maybe somebody could give me a hand. 也许有人可以帮我一臂之力。 Thanks! 谢谢!

The PHP I'm using is simple enough, just an ´exec()´ command as you can see below: 我正在使用的PHP很简单,只需一个'exec()'命​​令,如下所示:

exec('mysqldump --user='.$_SESSION['user'].' --password='.$_SESSION['password'].' --host=localhost myDatabase > C:\Users\Xavier\Dropbox\db_backups\file.sql');

OK! 好! So it seems I was able to get it to work. 所以我似乎能够让它发挥作用。

A little more research and I found this website: See the website 稍微研究一下,我找到了这个网站: 查看网站

Basically, it told me what path to follow in order to run the mysqldump on the Dbs in my Wamp server and everything was output as expected. 基本上,它告诉我要在我的Wamp服务器上的Dbs上运行mysqldump时要遵循的路径,并且所有内容都按预期输出。

My case is rather specific and perhaps many people don't share this need, but this is the result: 我的情况相当具体,也许很多人不同意这个需求,但结果如下:

exec('C:\wamp\bin\mysql\mysql5.6.12\bin\mysqldump --user='.$_SESSION['user'].' --password='.$_SESSION['password'].' --host=localhost myDatabase > C:\Users\Xavier\Dropbox\db_backups\file.sql');

By the way, thanks a lot to @MarcB and @mb14 for trying to help me out and posting their comments below! 顺便说一句,非常感谢@MarcB和@ mb14试图帮助我并在下面发表评论!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM