Skip to content
Starting MySQL Up On An Ubuntu Instance Managed by Vagrant
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 digital experience agency that helps our clients elevate their impact with beautiful technology. We provide the expertise and insight at every layer that makes a great digital experience for websites and applications possible. If you're committed to elevating your digital experience, contact us and we'd be happy to schedule a chat to see if we're a fit.

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

Back To Top