Error Provisioning: mariaDb fails at setting root user password

Hi! I’m trying to provision a Staging environment.

Everything goes well until task “mariadb : Set root user password”

"Access denied for user 'root'@'localhost' (using password: NO)")

Two things trouble me:

  • using password: NO, when i’ve specified a mysql_root_password
  • What does this mean: Trellis at “Add myhostname to nsswitch.conf to ensure resolvable hostname”

I’ve disabled root login, so everything has to be done via my user (who belongs to sudo) but that does not seem to cause any trouble for all the previous tasks.

I have tried putting back the “stagingwp” default password. To no avail. Why does it not pick up the password to login to mariaDb ?

Can you help me sort this out?

Here is the end part of the log, in case it helps:

TASK [sshd : ensure ssh server is installed] ***********************************
ok: [staging.example.com]

TASK [sshd : ensure sshd is configured] ****************************************
ok: [staging.example.com]

TASK [mariadb : Add MariaDB MySQL apt-key] *************************************
ok: [staging.example.com]

TASK [mariadb : Add MariaDB MySQL deb and deb-src] *****************************
ok: [staging.example.com] => (item=deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main)
ok: [staging.example.com] => (item=deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main)

TASK [mariadb : Install MySQL client] ******************************************
ok: [staging.example.com]

TASK [mariadb : Install MariaDB MySQL server] **********************************
ok: [staging.example.com]

TASK [mariadb : Disable MariaDB binary logging] ********************************
ok: [staging.example.com]

TASK [mariadb : Restart MariaDB MySQL Server] **********************************
changed: [staging.example.com]

TASK [mariadb : Set root user password] **************************************
System info:
  Ansible 2.2.0.0; Darwin
  Trellis at "Add myhostname to nsswitch.conf to ensure resolvable hostname"
---------------------------------------------------
unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
"Access denied for user 'root'@'localhost' (using password: NO)")
failed: [staging.example.com] (item=staging.example.com) => {"failed": true, "item": "staging.example.com"}
---------------------------------------------------
unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
"Access denied for user 'root'@'localhost' (using password: NO)")
failed: [staging.example.com] (item=127.0.0.1) => {"failed": true, "item": "127.0.0.1"}
---------------------------------------------------
unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
"Access denied for user 'root'@'localhost' (using password: NO)")
failed: [staging.example.com] (item=::1) => {"failed": true, "item": "::1"}
---------------------------------------------------
unable to connect to database, check login_user and login_password are
correct or /root/.my.cnf has the credentials. Exception message: (1045,
"Access denied for user 'root'@'localhost' (using password: NO)")
failed: [staging.example.com] (item=localhost) => {"failed": true, "item": "localhost"}
	to retry, use: --limit @/Users/aplennevaux/BITBUCKET/paris-match-wordpress-theme/parismatch.be/trellis/server.retry
1 Like

I’m experiencing the exact same thing. Same error. Same ansible role that’s not working. Anyone?

I have found a solution :champagne:. The problem is that ansible tries to set a root password where no password yet exists. What you have to do to get rid of the issue is: ssh to your remote server. Change to the root user sudo su - root open up the .my.cnf file. It should be in the root of your root user. Change your password to match the password you have set in group_vars/production/vault.yml. After you did that save the file and try to provision again. This should resolve the issue.

I hope someone experiencing the same problem will read this and have a nice day!

1 Like