Sharing databases is something that’s convenient to do within your local development environment especially if you’re working with multiple machines.
It is not necessary to install Dropbox or OneDrive software to use this feature, you only need a login to your Dropbox or OneDrive account through the MAMP PRO interface cloud settings. If you are using one or more databases for your selected host and you want them to be transferred to the cloud as well, these databases must be associated to. MAMP Cloud allows you to save and load your host and data from one database using Dropbox. This means you can work from any computer you need to – a real plus for digital nomads. This means you can work from any computer you need to – a real plus for digital nomads.
MAMP Cloud allows you to save and load your host and your data of one database using Dropbox. You can easily save your host and database data in the cloud and later retrieve it on another computer, or on the same computer, when backing up data before making changes on your host. How does MAMP Cloud work?
If for whatever reason you’re looking to do this with a staging environment or production environment, then this is not the way to do it. There are strategies like database replication and the like that are meant for that, and that are far beyond the scope of this post.
Instead, this is primarily intended for systems that you have, likely on the same network, and that you swap between during the day.
Sharing Databases
First, the whole idea behind sharing databases is to make it easy to work with the same set of information across multiple machines when working on small-ish projects. Since databases are nothing more than [intelligently managed] files, they can be stored and synchronized in software like Dropbox.
Secondly, although the example that I’m going to give is specifically for MAMP Pro, this is applicable not only to MAMP but other systems as well. You just need to know where your software of choice keeps its database files.
For MAMP Pro and on macOS, this is in the /Library/Application Support/appsolute/MAMP PRO
directory. More specifically, it’s in the db
subdirectory, but I’ll get to that momentarily.
And the idea behind sharing databases between (or among) machines is this:
- have Dropbox installed on each machine,
- have MAMP Pro (or your software of choice) installed on each machine,
- be comfortable with symbolic links (or shortcuts, if you’re on Windows).
Mamp Pro Dropbox
Since I’m on macOS, the following set of instructions are going to be specifically for that, but they can be tailored for other machines.
1. Backup Your Data
This should go without saying, but anything that’s located in the /Library/Application Support/appsolute/MAMP PRO/db
directory should be saved in case you make an error when setting up the shared resources.
To do this, copy (versus move) the db
directory to another place on your hard drive so that you can easily restore it if something goes wrong.
2. Create a Location in Dropbox
This is up to you, but I’m a fan of using an “Apps” directory out of which I create shared settings. Sometimes this is for editors, other times it’s for software like Transmit (as you see in the shot above), and I’m using it for sharing databases, too.
Map Dropbox To Drive Mac Os X
Note, however, that the name of the directory is important – at least to a degree. I prefer the name the directory based on the directory that it’s going to represent as I create a link between the two files.
So, for example, in Dropbox, I have /Apps/MAMP/db
since I have a db
directory on the hard drive.
3. Copy the Database to Dropbox
From there, I copy the db
directory from its original location on the hard drive to the location I’ve selected in Dropbox.
After that, I need to create a link.
4. Create a Symbolic Link
This is where things can break if you’re not careful. First, make sure MAMP is completely closed. Note that the syntax for symbolic links takes the destination directory first then the source directory second.
Next, I usually remove the db
directory from its original location. This isn’t something that has to be done, but I find it cleaner to start without anything in the MAMP directory such that when I create the symbolic link, that’s what it creates.
So open a Terminal window and enter the following command:
After that, verify your Dropbox directory contains the database files, as expected, and that your db
directory in MAMP is referencing an external directory (it will have an arrow overlay on it like this):
External Database Reference
Again, With the Local Environments
Map Dropbox Folder
To reiterate, this is something that I recommend only for local environments and something that I think you should do only if you aren’t dealing with sensitive data.
A Note From a Reader
Mamp Sync Database Dropbox
you also want to make sure only 1 machine has MySQL service running at a time.
— Scott Lesovic (@gMagicScott) February 15, 2017
Specifically, make sure that when you’re setting this up, you have your servers off. And when you move to a another machine, you turned MySQL off on the original machine.
Mamp Dropbox Sign In
Back on Target
Database replication across other machines is best left to the experts, and sharing sensitive information should be self-evident as to why this shouldn’t be stored in Dropbox.
Mamp Dropbox Account
Other than that, once all is said and done, load MAMP on your machines and you should see all of your data available across each machine and accessible from your favorite database front-end.