How to setup DB on bedrock-ansible?

I’m getting errors when doing vagrant provision:
failed: [default] => (item=cicc) => {“failed”: true, “item”: “cicc”}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [default] => (item=127.0.0.1) => {“failed”: true, “item”: “127.0.0.1”}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [default] => (item=::1) => {“failed”: true, “item”: “::1”}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials
failed: [default] => (item=localhost) => {“failed”: true, “item”: “localhost”}
msg: unable to connect to database, check login_user and login_password are correct or ~/.my.cnf has the credentials

Trying to understand where I went wrong… the bedrock-ansible directions aren’t very thorough for beginners.

@joshua The errors look similar to this, produced when config.vm.box = 'roots/bedrock' (in Vagrantfile) and mysql_root_password is not equal to the default: devpw (in group_vars/development).

If this applies to you, you might try setting mysql_root_password back to the default. Alternatively, you could adjust config.vm.box to use a different vagrant box, like 'ubuntu/trusty64'.

I’ve always gotten this error when changing the devpw, stagingpw, or productionpw variables. If I leave it as the default passwords, i don’t receive errors.

I would assume we’d want to change these, is there a different way to change the mysql_root_passwords?

Do you change it before or after you do your first vagrant up or provision?

i tried changing it before doing vagrant up - first thing…any ideas?

Maybe there’s another way, but I change the mysql_root_password in the group_vars/<environment> files, then adjust the Vagrantfile to config.vm.box = 'ubuntu/trusty64' to avoid the pre-provisioned mysql password in the roots/bedrock box. As @kalenjohnson alluded to, you’d use this approach with the very first provision. It wouldn’t work if you’ve already provisioned with the roots/bedrock box.

I don’t bother changing passwords when it’s a dev project that will be on my local machine only.

This should now actually be fixed with https://github.com/roots/trellis/pull/260

1 Like

I am unable to connect to my local database after https://github.com/roots/trellis/pull/260 using the existing credentials:
mysql host: 127.0.0.1
user: user
pw: password
ssh host: structuralbuildings.dev
ssh user: vagrant
ssh password: vagrant

I’d assume since the basebox changed, the ssh credentials need to be changed. Any ideas of what I’d use?

Figured it out in case others have this issue:
mysql host: 127.0.0.1
user: user
pw: password
ssh host: 127.0.0.1
ssh user: vagrant
ssh password: vagrant

1 Like