# ~/.my.cnf path

**URL:** <https://forum.ansible.com/t/my-cnf-path/21888>\
**Category:** Ansible Project\
**Created:** [June 29, 2016, 11:10am UTC](https://forum.ansible.com/t/my-cnf-path/21888 "2016-06-29T11:10:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdarwin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sdarwin/32/2450_2.png) [@sdarwin](https://forum.ansible.com/u/sdarwin)\
**Post date:** [June 29, 2016, 11:10am UTC](https://forum.ansible.com/t/my-cnf-path/21888/1 "2016-06-29T11:10:15Z")

</div>

Hi,

Question about the location of ~/.my.cnf . For ansible, would this refer to the “become” user’s home directory ( which is /root/.my.cnf ), or the ansible user’s home directory ( such as, during testing, /home/vagrant/.my.cnf ) ?

It seems that mysql\_user module is looking for the ansible user’s home directory because I get an error “msg”: “unable to connect to database, check login\_user and login\_password are correct or /home/vagrant/.my.cnf has the credentials. Exception message: (1045, "Access denied for user ‘root’@‘localhost’ (using password: NO)")”}

which then leads to the next question, what does the copy module consider to be ~/.my.cnf ?

- name: create .my.cnf file  
copy: content=“[client]\nuser=root\npassword={{ mysql\_root\_password }}” dest=~/.my.cnf

This places the file in /root/.my.cnf

The copy module and mysql\_user module do not interpret the same ~/.my.cnf ?

More information:

In [http://docs.ansible.com/ansible/mysql\_user\_module.html](http://docs.ansible.com/ansible/mysql_user_module.html) it says “MySQL server installs with default login\_user of ‘root’ and no password. To secure this user as part of an idempotent playbook, you must create at least two tasks: the first must change the root user’s password, without providing any login\_user/login\_password details. The second must drop a ~/.my.cnf file containing the new root credentials. Subsequent runs of the playbook will then succeed by reading the new credentials from the file.”
