# mysql\_db module issue

**URL:** <https://forum.ansible.com/t/mysql-db-module-issue/30067>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [April 4, 2019, 6:14pm UTC](https://forum.ansible.com/t/mysql-db-module-issue/30067 "2019-04-04T18:14:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Muriithi](https://avatars.discourse-cdn.com/v4/letter/w/6de8d8/32.png) [@William\_Muriithi](https://forum.ansible.com/u/William_Muriithi)\
**Post date:** [April 4, 2019, 6:14pm UTC](https://forum.ansible.com/t/mysql-db-module-issue/30067/1 "2019-04-04T18:14:49Z")

</div>

Hello,

I have an old task that works on an previous system but fail to work in the new system. I am certain it hasn’t changed through git log but I have updated ansible on control system. I don’t see other people raising the issue so not confident it’s a bug. Have anyone observed something similar?

Version:  
control machine: Centos 7  
managed system: RHEL 7  
ansible: ansible-2.7.9-1.el7.noarch

Task currently:

- name: create projectsend database schema  
mysql\_db: name={{database\_name}} encoding=utf8mb4 collation=utf8mb4\_bin state=present state=present login\_user=root login\_password=“{{root\_db\_password}}”

Task previously:

- name: create projectsend database schema  
mysql\_db: name={{database\_name}} encoding=utf8mb4 collation=utf8mb4\_bin state=present state=present

None of the above tasks works on a new system, they work fine though on a previous system. I can login fine to mysql without having to use the password, so details on /root/.my.cnf are fine. What could be causing this?

The full traceback is:  
WARNING: The below traceback may _not_ be related to the actual failure.  
File “/tmp/ansible\_mysql\_db\_payload\_bZdCNZ/ **main**.py”, line 316, in main  
connect\_timeout=connect\_timeout)  
File “/tmp/ansible\_mysql\_db\_payload\_bZdCNZ/ansible\_mysql\_db\_payload.zip/ansible/module\_utils/mysql.py”, line 79, in mysql\_connect  
db\_connection = mysql\_driver.connect(\*\*config)  
File “/usr/lib/python2.7/site-packages/pymysql/ **init**.py”, line 94, in Connect  
return Connection(\*args, \*\*kwargs)  
File “/usr/lib/python2.7/site-packages/pymysql/connections.py”, line 327, in **init**  
self.connect()  
File “/usr/lib/python2.7/site-packages/pymysql/connections.py”, line 598, in connect  
self.\_request\_authentication()  
File “/usr/lib/python2.7/site-packages/pymysql/connections.py”, line 862, in \_request\_authentication  
auth\_packet = self.\_process\_auth(plugin\_name, auth\_packet)  
File “/usr/lib/python2.7/site-packages/pymysql/connections.py”, line 933, in \_process\_auth  
pkt = self.\_read\_packet()  
File “/usr/lib/python2.7/site-packages/pymysql/connections.py”, line 683, in \_read\_packet  
packet.check\_error()  
File “/usr/lib/python2.7/site-packages/pymysql/protocol.py”, line 220, in check\_error  
err.raise\_mysql\_exception(self.\_data)  
File “/usr/lib/python2.7/site-packages/pymysql/err.py”, line 109, in raise\_mysql\_exception  
raise errorclass(errno, errval)

fatal: [[projectsend.eng.example.com](http://projectsend.eng.example.com/)]: FAILED! =\> {  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“collation”: “utf8mb4\_bin”,  
“config\_file”: “/root/.my.cnf”,  
“connect\_timeout”: 30,  
“encoding”: “utf8mb4”,  
“ignore\_tables”: ,  
“login\_host”: “localhost”,  
“login\_password”: “VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER”,  
“login\_port”: 3306,  
“login\_unix\_socket”: null,  
“login\_user”: “root”,  
“name”: “projectsend\_db”,  
“quick”: true,  
“single\_transaction”: false,  
“ssl\_ca”: null,  
“ssl\_cert”: null,  
“ssl\_key”: null,  
“state”: “present”,  
“target”: null  
}  
},  
“msg”: “unable to connect to database, check login\_user and login\_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, u"Access denied for user ‘root’@‘localhost’ (using password: YES)")”  
}  
to retry, use: --limit @/etc/ansible/site.retry

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[projectsend.eng.example.com](http://projectsend.eng.example.com/) : ok=3 changed=0 unreachable=0 failed=1

Regard,  
William

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [April 4, 2019, 6:27pm UTC](https://forum.ansible.com/t/mysql-db-module-issue/30067/2 "2019-04-04T18:27:22Z")

</div>

Hi,

it could be related to the change from MySQLdb to PyMySQL; see  
[https://github.com/ansible/ansible/issues/47736](https://github.com/ansible/ansible/issues/47736) and in particular  
[https://github.com/ansible/ansible/issues/47736#issuecomment-479745979](https://github.com/ansible/ansible/issues/47736#issuecomment-479745979)

I wouldn't be surprised if you have PyMySQL installed on the new  
system, and MySQLdb installed on the old one. That would explain why  
one works and the other doesn't.

Cheers,  
Felix
