I have cloned bedrock-ansible and set up a bedrock wp site and downloaded sage into its theme’s dir.
When I run vagrant up it fails at wordpress-sites:
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>localhost</code>. This could mean your host's database server is down.</p>
<ul>
<li>Are you sure you have the correct username and password?</li>
<li>Are you sure that you have typed the correct hostname?</li>
<li>Are you sure that the database server is running?</li>
</ul>
<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>
stdout:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /srv/www/lifepluspizza.dev/current/web/wp/wp-includes/wp-db.php on line 1416
FATAL: all hosts have already failed -- aborting
I’ve set up my own linux servers as I do my own hosting but I have no clue how this works. Can someone pleae give me some directions as to what to do immediatly upon cloning bedrock-ansible? I’ve followed the docs exactly, and nowhere in there does it mention anything about setting up a db. I even found an old closed issue: https://github.com/roots/bedrock-ansible/issues/73
were it not for finding this, I would not have realised that we can’t change the passwords in group_vars/development without breaking install. So I did this and am now stuck with the issues raised above.
Here are my settings in group_vars:
The error message is pretty self-explanatory. Are you sure your database and password that is set up in your .env file are working in your bedrock-ansible VM?
Hmm I didn’t set up .env files because I read somewhere here (looking for which comment) that ansible is responsible for creating them.
I’ve set all of this up before just fine, but not with ansible.
Ok so looking at my projects site dir, there is an aliased .env file. The alias points to /srv/www/lifepluspizza.dev/shared/.env
I ssh into vagrant and find this file and open it with nano.
I see that all the information in there is indeed what I entered into group_vars, so indeed, ansible did generate this file.
What I am confused about is the database. Do I manually create a database within vagrant? Or do I create this database in my local database running on my mac?
TASK: [mariadb | Set root user password] **************************************
failed: [default] => (item=lifepluspizza) => {"failed": true, "item": "lifepluspizza"}
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
FATAL: all hosts have already failed -- aborting
Ok started from scratch new settings, changing mysql_root_password and got:
TASK: [mariadb | Set root user password] **************************************
failed: [default] => (item=lifepluspizza) => {"failed": true, "item": "lifepluspizza"}
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
FATAL: all hosts have already failed -- aborting
Reverted mysql_root_password to devpw as suggested on issue 73 and this time got the first error again: Error establishing a database connection.
EDIT: I’ve at least progressed as far as being able to connect to the database and grant privelages to the user for the table via Querius. But running provision again yields the same error.
UPDATE2:30am I created a new test project, ran vagrant up not chaning any settings. Everything ran fine with no errors and wordpress is up and running. Something about changing passowords seems to break everything.
Just in case you were only doing a vagrant provision after each edit, a vagrant destroy and vagrant up might have cleaned things up (I realize you probably DID try the destroy each time).
If ever there’s any question still related to issue 73, you could swap config.vm.box = 'roots/bedrock'
with config.vm.box = 'ubuntu/trusty64'
in your Vagrantfile. It would just take longer to provision.
The next thing I was going to suggest was to vagrant ssh and service mysql restart but it sounds like you’re all set. Congrats.
Well I’m almost there! The error still persists, I don’t know what password I am being asked for. I tried switching them to their defaults but I get the same error. I will try your suggestions again, and again thanks for your time!
edit argh I want to scream! I hate being so close!
I thought, nahhh it couldn’t be that. I forgot I even trialled it. Just. Wow.
So… how do we get hhvm working hahhahahahah
I can now go for a nap knowing that when I’m back, I can finally get into Sage, woo! Thank you for your company as I dived into this rabbit hole.
Should I open an issue regarding the database not working with hhvm or is that expected?
One thing to note is that unless you have restructured Bedrock, wp_siteurl should always have /wp the end.
I haven’t had the chance to play with the HHVM install. But will give it a go with and without the password changing. I vaguely remember Scott mentioning that you wouldn’t be able to switch between HHVM and the standard setup, so perhaps you missed a vagrant destroy somewhere along the way.
@foxaii Its my own fault, I always put myself at the edge of my comprehension way before I know what I am doing. In a way its how I keep learning and growing. Other times it can lead to frustration!
Still no luck with this. The issue appears to be that the new WP site is trying to login to the existing homebrew MySQL install @ localhost.
I don’t have much experience with Vagrant or MariaDB, but should there be a port to point bedrock’s wp install to the Vagrant MariaDB? What directs the WP site to the new MariaDB in the Vagrant VM?
Not sure if this should be another thread or just a continuation of this one, but I did post this yesterday.