Backup mySQL databases from localhost running on Wamp server

萝らか妹 提交于 2019-12-08 08:59:39

问题


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. I've tried several things, including setting the exact path of the SQL data within my Wamp folder, but to no avail.

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:

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

回答1:


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.

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!



来源:https://stackoverflow.com/questions/19989258/backup-mysql-databases-from-localhost-running-on-wamp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!