# Unable to reset mysql root password after fresh install mariadb-server

**URL:** <https://forum.ansible.com/t/unable-to-reset-mysql-root-password-after-fresh-install-mariadb-server/6596>\
**Category:** Get Help\
**Tags:** mysql, mariadb\
**Created:** [June 17, 2024, 12:31pm UTC](https://forum.ansible.com/t/unable-to-reset-mysql-root-password-after-fresh-install-mariadb-server/6596 "2024-06-17T12:31:51Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [June 17, 2024, 2:23pm UTC](https://forum.ansible.com/t/unable-to-reset-mysql-root-password-after-fresh-install-mariadb-server/6596/6 "2024-06-17T14:23:15Z")

</div>

Does something like this work?

```yaml
- name: Update MySQL root password
  community.mysql.mysql_user:
    name: "{{ db_user }}"
    password: "{{ db_pass }}"
    login_user: root
    config_file: /root/.my.cnf
  register: root_user

- name: Debug root_user
  ansible.builtin.debug:
    var: root_user

```

Note that once you change the `root` password you will also need to update the `/root/.my.cnf` file, you can use the [ini\_file module](https://docs.ansible.com/ansible/latest/collections/community/general/ini_file_module.html) for this since MySQL configuration files use the INI format.

---

_[View the full topic](https://forum.ansible.com/t/unable-to-reset-mysql-root-password-after-fresh-install-mariadb-server/6596)._
