# mysql\_db : how to specify the server port

**URL:** <https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155>\
**Category:** Ansible Project\
**Created:** [July 18, 2013, 3:15pm UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155 "2013-07-18T15:15:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marian\_ZUREK](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@Marian\_ZUREK](https://forum.ansible.com/u/Marian_ZUREK)\
**Post date:** [July 18, 2013, 3:15pm UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/1 "2013-07-18T15:15:47Z")

</div>

I am trying to use the mysql\_db module for the database creation in a following way:

- name: Create Application Database  
mysql\_db: name={{ dbname }} state=present login\_host={{ db\_server }} login\_password={{ admin\_password }} login\_user={{ admin\_user }}

and also

- name: Create Application Database v2

mysql\_db: name={{ dbname }} state=present login\_host={{ db\_server }}

My database is running on the port != 3306, so need to specify it somewhere.

I have put it into ~/.my.cnf and also into /etc/my.cnf, but the module mysql\_db does not take it into account.

~/.my.cnf == /etc/my.cnf

[client]  
port=5501  
user=admin  
password=ABRACADABRA

When using the command-line : mysql -h db-host-here I am connecting seamlessly

I am using RH Linux v6.4

The connection uisng python from the same host

import MySQLdb

db = MySQLdb.connect(host="…, port=5501)

works without any troubles

Thank you for your comments.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 18, 2013, 9:03pm UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/2 "2013-07-18T21:03:51Z")

</div>

Have you tried servername:port ?

---

<div class="post-metadata">

**Author:** ![Marian\_ZUREK](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@Marian\_ZUREK](https://forum.ansible.com/u/Marian_ZUREK)\
**Post date:** [July 18, 2013, 10:31pm UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/3 "2013-07-18T22:31:17Z")

</div>

Yes, I did. No luck.  
Looked into the source code. The port is not used at all.

Manieq

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 19, 2013, 12:01am UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/4 "2013-07-19T00:01:42Z")

</div>

Ok please make sure there’s a ticket filed on this one.

I _believe_ it will respect your my.cnf but I don’t think that should be required personally.

I’m generally a PostgreSQL user so perhaps the various folks who work on/with this module would like to work on this.

---

<div class="post-metadata">

**Author:** ![Marian\_ZUREK](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@Marian\_ZUREK](https://forum.ansible.com/u/Marian_ZUREK)\
**Post date:** [July 19, 2013, 9:40am UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/5 "2013-07-19T09:40:56Z")

</div>

No problem. Please explain me how do I create / add a ticket?  
I did not do it in the past. Here or on the github?

Thanks,  
Manieq

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 19, 2013, 9:48am UTC](https://forum.ansible.com/t/mysql-db-how-to-specify-the-server-port/13155/6 "2013-07-19T09:48:54Z")

</div>

​[Issues · ansible/ansible · GitHub](https://github.com/ansible/ansible/issues)

! [image.png|109x42](https://forum.ansible.com/uploads/short-url/wrOWjSNULbwPbX5RDbctxC6dM0M.png)​
