Keep database synced between computers in Trellis/Bedrock/Sage setup

Thanks fullyint!

I read up on the Synced Folders option in Vagrant and tried adding the following line to my Vagrantfile:

config.vm.synced_folder "../db", "/var/lib/mysql/example_wp", owner: "root", group: "root"

and added the folder db in my main project folder.
When running vagrant up the folder seems to be mounted correctly:

==> default: Mounting NFS shared folders...
==> default: Mounting shared folders...
    default: /vagrant =>~/Dropbox/Websites/example/ansible
    default: /var/lib/mysql/example_wp => ~/Dropbox/Websites/example/db
==> default: Creating bind mounts for selected devices
==> default: Creating bind mount from /vagrant-nfs-example to /srv/www/example/current

But should it also be binded like the site_path?
Because when I go to /wp/wp-admin/ I get the Wordpress installation screen which shouldn’t happen and in the next step I get loads of errors saying:

WordPress database error: [Can't create table `example_wp`.`mydbprefix_users` (errno: 13 "Permission denied")]

So I was wundering what the file permissions should be of the synced folder? I also tried:

config.vm.synced_folder "../db", "/var/lib/mysql/example_wp", u: 'vagrant', g: 'www-data'

with the same result.

Another question; How can I use the database name variable set in group_vars/development in my vagrantfile?

env:
  db_name: example_wp

Would this work:

wp_db = site['env']['db_name']
config.vm.synced_folder "../db", "/var/lib/mysql/#{wp_db}", u: 'vagrant', g: 'www-data'

Thanks for the help so far!