# Problem when attempting to create database with ansible

**URL:** <https://forum.ansible.com/t/problem-when-attempting-to-create-database-with-ansible/31278>\
**Category:** Ansible Project\
**Created:** [September 13, 2019, 6:54pm UTC](https://forum.ansible.com/t/problem-when-attempting-to-create-database-with-ansible/31278 "2019-09-13T18:54:14Z")\
**Posts on this page:** 1\
**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:** [September 13, 2019, 6:54pm UTC](https://forum.ansible.com/t/problem-when-attempting-to-create-database-with-ansible/31278/1 "2019-09-13T18:54:14Z")

</div>

Hello,

Have anyone attempted to use ansible to create database on mariaDB system recently. I am having a problem and would appreaciate advice.

I have two tasks:

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

- name: add nextcloud database user  
mysql\_user: name={{mysql\_username}} password={{mysql\_password}} priv=‘{{database\_name}}.\*:SELECT,INSERT,UPDATE,DELETE,DROP,CREATE,ALTER,INDEX,REFERENCES’ state=present check\_implicit\_admin=yes

They run fine if I am using mysql but are broken when the database is Maria. They fails with this error:

TASK [nextcloud : create nextcloud database schema] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [[nextcloud.eng.perasotech.com](http://nextcloud.eng.perasotech.com)]: FAILED! =\> {“changed”: false, “msg”: “unable to connect to database, check login\_user and login\_password are correct or /root/.my.cnf has the credentials. Exception message: (1045, "Access denied for user ‘root’@‘localhost’ (using password: YES)")”}

The thing is, I do have /root/.my.cnf and infact can login to mysql without password. There is a slight difference when I login manually though and I suspect its what is causing me the pain. See below at the differences, the first being mysql and the other two sessions being MariaDB

Would you know what happening here by any chance? Would really appreaciate your help.

[root@oxygen ~]# mysql -u root  
Welcome to the MySQL monitor. Commands end with ; or \g.  
Your MySQL connection id is 87077  
Server version: 5.7.26-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its  
affiliates. Other names may be trademarks of their respective  
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

> exit  
> Bye  
> [root@oxygen ~]# exit

[root@nextcloud ~]# mysql -u root  
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)  
[root@nextcloud ~]#

[root@nextcloud ~]# mysql -u root -p  
Enter password:  
Welcome to the MariaDB monitor. Commands end with ; or \g.  
Your MariaDB connection id is 16  
Server version: 10.3.11-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]\>

Regards,  
William
