# suggestion for using ~/.my.cnf file

**URL:** <https://forum.ansible.com/t/suggestion-for-using-my-cnf-file/24400>\
**Category:** Ansible Project\
**Created:** [May 4, 2017, 7:12pm UTC](https://forum.ansible.com/t/suggestion-for-using-my-cnf-file/24400 "2017-05-04T19:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swathi\_Cutie](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@Swathi\_Cutie](https://forum.ansible.com/u/Swathi_Cutie)\
**Post date:** [May 4, 2017, 7:12pm UTC](https://forum.ansible.com/t/suggestion-for-using-my-cnf-file/24400/1 "2017-05-04T19:12:57Z")

</div>

I am new to ansible i want to execute my command like this

```auto
zact /usr/share/doc/zabbix-server-mysql-3.0.9/create.sql.gz| mysql -u zabbix -p zabbixdb

```

Ansible\_code:

```auto
- name: Import the initial schema
  mysql_db:
          state: import
          login_user: zabbix
          login_password: 1234
          name: zabbixdb
          target: /usr/share/doc/zabbix-server-mysql-3.0.9/create.sql.gz
  run_once: true

```

Output\_error:

```auto
     failed: [10.100.140.230] => {"failed": true}
msg: unable to connect, check login credentials (login_user, and login_password, which can be defined in ~/.my.cnf), check that mysql socket exists and mysql server is running

```

I cannot create this file ~/.my.cnf using template since i am using ansible 1.9.6 and config file in used in higher versions of ansible Can someone please suggest me a workaround for this.

Ansible\_Version:

```auto
ansible --version
ansible 1.9.6 (stable-1.9 b377301195) last updated 2017/04/09 00:47:37 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 746d51d1ff) last updated 2017/04/09 00:47:59 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD 2c073442b0) last updated 2017/04/09 00:48:19 (GMT -400)
  configured module search path = /opt/ansible/library

```

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [May 4, 2017, 8:04pm UTC](https://forum.ansible.com/t/suggestion-for-using-my-cnf-file/24400/2 "2017-05-04T20:04:30Z")

</div>

You already provide a user and password. Is the mysql server running?

---

<div class="post-metadata">

**Author:** ![Marcus\_Franke1](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Marcus\_Franke1](https://forum.ansible.com/u/Marcus_Franke1)\
**Post date:** [May 5, 2017, 10:04am UTC](https://forum.ansible.com/t/suggestion-for-using-my-cnf-file/24400/3 "2017-05-05T10:04:50Z")

</div>

the "config\_file" option has been added in 2.0, but it is not available  
with your elderly 1.9.6.

by default login\_host points to localhost, maybe your database isn't  
listening on localhost?

you could check your settings in the shell:  
mysql -u zabbix -p1234 -h 127.0.0.1 zabbixdb

Regards,  
Marcus
