# Problem with mysql core modules when host and/or port are non default

**URL:** <https://forum.ansible.com/t/problem-with-mysql-core-modules-when-host-and-or-port-are-non-default/21364>\
**Category:** Ansible Project\
**Created:** [May 5, 2016, 3:07pm UTC](https://forum.ansible.com/t/problem-with-mysql-core-modules-when-host-and-or-port-are-non-default/21364 "2016-05-05T15:07:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jurgen\_Haas2](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@Jurgen\_Haas2](https://forum.ansible.com/u/Jurgen_Haas2)\
**Post date:** [May 5, 2016, 3:07pm UTC](https://forum.ansible.com/t/problem-with-mysql-core-modules-when-host-and-or-port-are-non-default/21364/1 "2016-05-05T15:07:58Z")

</div>

According to the docs, Ansible started to support the config file (default: ~/.my.cnf) when connecting to the MySQL database and it reads the username and password from that file to be used when the arguments for login\_user and login\_password are not provided.

However, the same should be the case for login\_host and login\_port, but that doesn’t work because the main() functions in mysql\_db and mysql\_user modules are defaulting to localhost and 3306.

As a result, those default values get used when no module arguments are provided but that means that values for host and port in ~/.my.cnf won’t be used when provided there.

Proposal: both, login\_host and login\_port should default to none in both the mysql\_db and mysql\_user modules. Then, in mysql\_connect their values should be added to the config list if they were provided as arguments, just exactly like already done with login\_user and login\_password.

Thoughts?
