Wondering about host Vs. guest for databases

With or without Trellis, I’m using Vagrant for almost all development these days. One aspect that seems a little inconvenient in my workflow is databases.

I understand that Trellis’ creators feel very strongly that database and database software belong on the VM - however, I’m wondering about the pros and cons of running MariaDB on my Mac (very easily achieved using Homebrew) and storing all databases on my host Mac.

The con is obviously breaking from Trellis’ standard workflow, and the issue of potential software and setup incompatibilities.

However, the pros seem strong to me:

  • A simple way to backup and monitor all databases.
  • Immediate access to databases, regardless of the state of the VM.
  • Easier config/management for GUI apps, such as Sequel Pro.
  • Standard user/host setup for every dev install.

I haven’t begun thinking about HOW to achieve this, I believe I could do it. Right now I’m wondering more about whether I SHOULD do this.

Any feedback/thoughts welcome.

Generally - You shouldn’t do this. It’s like using (W/X/L/M)AMP only for “M” part, but is as bad as using whole (W/X/L/M)AMP.

My usual deployments are done to environments where databases are on dedicated database hosts with configs & hardware optimized towards database workflow… So I try to mimic that on my dev environments - I have separate VM (which btw is configured almost exactly like production database cluster) and wordpress vms simply connect to that one. Plus that setup covers completely You points 1,2 & 4 :smile: Aaand if needed, I guess You can easily configure some app to reach to VM for database connection, so point 3 is covered too.

What do You think?

1 Like

Thanks for the response.

I do see the value of mirroring dev and staging/production environments, but in my experience, very, very few incompatibilities are a result of MySQL settings or versions (especially with Wordpress).

I guess here’s my direct issue: I work on around 15 - 20 sites over the course of a year, each sitting on it’s own VM, each being upped and halted fairly frequently. The critical files sit on the shared folders, but the databases exist as 15 - 20 standalone entities, each with their own config. I have no idea what the status of each is without running vagrant up on each and every VM. Doesn’t this seem odd to anyone else - within the DRY or ‘snowflake server’ mentality?

Within the standard VM workflow, I could setup a script to dump the db at whatever intervals I like - however, that’s one more thing to configure, manage, maintain and test.

Wait what? No we don’t

So here’s my suggestion. As austin said, it’s not that anyone says you MUST use the database on the VM. But it’s not expected for you to have a database server set up on your host machine. And as @Johnny_Bit points out, you are potentially losing dev/prod parity and going back to the M in WAMP by doing that. Will you have issues with database servers? Probably not, but there is the possibility.

You mention having to vagrant up every VM when you work on a project. However, the VM still runs your site, so I’m not sure what you’d be gaining by moving the database off the VM, other than having access to it when the VM is not running. I don’t know if I would personally find that beneficial.

Trellis is able to run multiple sites off one box/installation, so perhaps if you are able to have multiple sites on a DO droplet or use the same Trellis installation to provision a few of them, you could also solve this by running multiple sites using one or a couple Trellis installs.

2 Likes

@austin lol, okay, I might have inferred that… I know the intention is for users to make Trellis what we want it to be, but I don’t see anyone else struggling with this - not sure if that’s because most people are working on fewer sites over any period of time than I am, or if there’s some reason I wasn’t aware of why the db and mysql should remain on the VM.

@kalenjohnson I’m kind of doing this already in certain cases. Generally I access one site at a time (db, config, files and all) but if I vagrant up and for some reason the VM doesn’t load, I can get the files - in order to get the database, I need to get the VM up and running and hope that whatever caused the problem didn’t affect software or config.

I think I have my answer - thanks for the feedback, all. :slight_smile: