# I an remote to server and login using root just fine, but ansible task is failing

**URL:** <https://forum.ansible.com/t/i-an-remote-to-server-and-login-using-root-just-fine-but-ansible-task-is-failing/26315>\
**Category:** Ansible Project\
**Created:** [December 17, 2017, 8:32pm UTC](https://forum.ansible.com/t/i-an-remote-to-server-and-login-using-root-just-fine-but-ansible-task-is-failing/26315 "2017-12-17T20:32:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitted](https://avatars.discourse-cdn.com/v4/letter/g/b77776/32.png) [@gitted](https://forum.ansible.com/u/gitted)\
**Post date:** [December 17, 2017, 8:32pm UTC](https://forum.ansible.com/t/i-an-remote-to-server-and-login-using-root-just-fine-but-ansible-task-is-failing/26315/1 "2017-12-17T20:32:50Z")

</div>

My task throws an error as follows:

TASK [mysql : Update MySQL root password for all root accounts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [1.2.3.4] (item=127.0.0.1) =\> {“changed”: false, “item”: “127.0.0.1”, “msg”: “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: YES)")”}  
failed: [1.2.3.4] (item=::1) =\> {“changed”: false, “item”: “::1”, “msg”: “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: YES)")”}  
failed: [1.2.3.4] (item=localhost) =\> {“changed”: false, “item”: “localhost”, “msg”: “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: YES)")”}

If I remote into the user using the user ‘deploy’ I can do the following just fine:

mysql -h 127.0.0.1 -u root -p

And it logs into the mysql server.

Why is it having an issue with ansible doing it?

my main yml file is doing this:

remote\_user: deploy  
become: yes  
become\_method: sudo  
gather\_facts: no

mysql/tasks/main.yml is:
