skip to Main Content
Starting MySQL up on an Ubuntu instance managed by Vagrant
Director of Engineering
February 14 2019

How to run commands when starting up a Vagrant box

Some of us at Culture Foundry run vagrant instances for development. This virtual machine lets you manage different environments or work in a unix environment if that is your wish. It’s heavier weight than a solution like docker, but depending on your infrastructure and/or sysadmin skills, may be more intuitive.

Our development depends on a database, which may be PostgreSQL or MySQL. However, for the version of Ubuntu that we were running, MySQL didn’t start up, at least the version we were using. After some searching, the easiest solution to implement was just to put the startup script in the Vagrant file. This looks like:

config.vm.provision "shell", inline: "sudo service mysql start", run: "always"

You can use this syntax to run any command you want run once and only once as your Vagrant machine boots up. More on the shell provisioner here.

Culture Foundry is a next-level digital agency that helps you thrive in digital. We build, evolve and support websites and applications for clients who are graduating to the next level of complexity in their digital ventures. Our uncommon strengths are headless CMS architectures, design systems and 24/7 support. If you're not thriving in digital, you can be: Contact us to learn more.

(Psst! We also happen to be a great place to work.)

Back To Top