# MySQL DB module behavior

**URL:** <https://forum.ansible.com/t/mysql-db-module-behavior/33937>\
**Category:** Ansible Project\
**Created:** [October 1, 2020, 6:26am UTC](https://forum.ansible.com/t/mysql-db-module-behavior/33937 "2020-10-01T06:26:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 1, 2020, 6:26am UTC](https://forum.ansible.com/t/mysql-db-module-behavior/33937/1 "2020-10-01T06:26:25Z")

</div>

Hello,

I need somes precisions about mysql\_db module. I try to create Apache Guacamole role.

This is my playbook:

FIRST TASK:

- name: Creation databases guacamole  
community.mysql.mysql\_db:  
login\_host: “{{ database\_ip }}”  
login\_user: root  
login\_password: “{{ mariadb\_root\_pass }}”  
name: “guacamole\_db”  
encoding: utf8  
state: present

SECOND TASK:

- name: Install database MySQL  
community.mysql.mysql\_db:  
login\_host: “{{ database\_ip }}”  
login\_user: root  
login\_password: “{{ mariadb\_root\_pass }}”  
name: “guacamole\_db”  
state: import  
target: “/srv/live/{{ app\_name }}/initdb.sql”

When variable “{{ database\_ip }}” is set to **localhost**  
First Task works,

Second Task,

I get this error:

“msg”: “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)\n”

When variable “{{ database\_ip }}” is set to **127.0.0.1**  
Two tasks work.

My MariaDB is in Docker with port 3306 expose.

Thanks
