5

I'm working on a project, but always have to switch between 2 computers. I need to sync source code and database between 2 computers, so I can do my job on computer 1 at the morning, then continue the job on computer 2 at the evening.

To sync source code, I use git with pull/push action, but it's harder to sync database. My idea is use dropbox and some folders syncing software to auto sync between mysql/data/mydb folder and dropbox folder on computer 1, then auto sync between dropbox folder and mysql/data/mydb folder on computer 2. But then I realized that databases can't be copied that way, it just created an empty database.

Is there a way to move database via copying files, or another way to have my project done on 2 computers?

10
  • possible duplicate of git repository sync between computers, when moving around?
    – user1864610
    Dec 12, 2014 at 4:47
  • Why not just set up a remote MySQL database somewhere? You could also use SQLite for file-based databases if your project has a quick way to switch to that (e.g. Symfony)
    – sjagr
    Dec 12, 2014 at 4:50
  • @sjagr I tried but that'd make the local site run too slowly
    – Mee
    Dec 12, 2014 at 4:52
  • @HoboSapiens but I want to move my database around, git can't do it. I don't want to export/import my db everytime there is a change.
    – Mee
    Dec 12, 2014 at 4:54
  • You tried both? I mean you could do a master-slave replication but that wouldn't be too fun. How about two bat scripts that does a mysqldump and vice-versa before you git push/pull?
    – sjagr
    Dec 12, 2014 at 4:54

2 Answers 2

2

Use portable XAMPP (download from here)

You can install the server inside a portable hard drive or pen drive and then run the server from there.

2
  • That's simple but a good idea. That way I will put the whole xampp folder into git and just pull/push to sync both source code and database. But I'm not sure if it really work, I must test to make sure before make your answer accepted. Thanks a lot!
    – Mee
    Dec 12, 2014 at 6:50
  • Hi, sorry for late reply. I tried putting whole portable xampp folder in git, at first it doesn't work as pulled xampp can't be run on the other computer, but with some tricks, it worked now.
    – Mee
    Dec 27, 2014 at 4:30
0

My suggestion is use git version control to sync your code. And for database use common database and while connection connect db with IP of another computer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.