unable to find /root/.my.cnf. Exception message: (1698, “Access denied for user ‘root’@’localhost'”)

I really need some help, i’m trying this for almost 3 days, searching on google, chatgpt, forums and anything.

I’m trying to create and environment with Ansible to WordPress with MariaDB, but i’m getting almost the same errors while trying to create the database and to create a new user with privileges on Oracle Linux (9.4) or Fedora (40).

The inventory is:

[fedora]
192.168.1.200 ansible_ssh_user=leo hostname=fedorasrv01 

[oracle]
192.168.1.202 ansible_ssh_user=leo hostname=oraclesrv01

This is the ansible playbook:

- name: Install Mariadb Server - RedHat
  yum:
    name:
      - mariadb-server
      - python3-pip
    state: present
  when: (ansible_facts['os_family'] == "RedHat")

- name: Install PyMySQL on RedHat
  ansible.builtin.pip:
    name: PyMySQL
    state: present
  when: (ansible_facts['os_family'] == "RedHat")

- name: "Start MariaDB"
  service:
    name: mariadb
    state: started
    enabled: yes

- name: Creating a database to be used by WordPress - RedHat
  mysql_db:
    name: "{{ db_wp_name }}"
    state: present
  when: (ansible_facts['os_family'] == "RedHat")

- name: Create user with password, all database privileges - RedHat
  mysql_user:
    name: "{{ db_wp_username }}"
    password: "{{ db_wp_password }}"
    priv: "{{ db_wp_name }}.*:ALL,GRANT"
    state: present
  when: (ansible_facts['os_family'] == "RedHat")

These are the errors:

TASK [mysql : Creating a database to be used by WordPress - RedHat] ***************************************************************************************************************************************************************************
fatal: [192.168.1.202]: FAILED! => {"changed": false, "msg": "unable to find /root/.my.cnf. Exception message: (1698, "Access denied for user 'root'@'localhost'")"}
fatal: [192.168.1.200]: FAILED! => {"changed": false, "msg": "unable to find /root/.my.cnf. Exception message: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")"}

During the seek, I tried to use another yml to help, calling it before the step that broke the pipeline.

- name: Stop MySQL
  service: name=mysqld state=stopped
- name: set environment variables
  shell: systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
- name: Start MySQL
  service: name=mysqld state=started
- name: sql query
  command:  mysql -u root --execute="UPDATE mysql.user SET authentication_string = PASSWORD('{{ mysql_root_password }}') WHERE User = 'root' AND Host = 'localhost';"
- name: sql query flush
  command:  mysql -u root --execute="FLUSH PRIVILEGES"
- name: Stop MySQL
  service: name=mysqld state=stopped
- name: unset environment variables
  shell: systemctl unset-environment MYSQLD_OPTS
- name: Start MySQL
  service: name=mysqld state=started

But after this, the errors now are:

TASK [mysql : sql query] **********************************************************************************************************************************************************************************************************************
fatal: [192.168.1.200]: FAILED! => {"changed": true, "cmd": ["mysql", "-u", "root", "--execute=UPDATE mysql.user SET authentication_string = PASSWORD('Password123') WHERE User = 'root' AND Host = 'localhost';"], "delta": "0:00:00.087770", "end": "2024-07-02 07:06:47.621171", "msg": "non-zero return code", "rc": 1, "start": "2024-07-02 07:06:47.533401", "stderr": "ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable", "stderr_lines": ["ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable"], "stdout": "", "stdout_lines": []}
fatal: [192.168.1.202]: FAILED! => {"changed": true, "cmd": ["mysql", "-u", "root", "--execute=UPDATE mysql.user SET authentication_string = PASSWORD('Password123') WHERE User = 'root' AND Host = 'localhost';"], "delta": "0:00:00.088495", "end": "2024-07-02 07:06:47.591159", "msg": "non-zero return code", "rc": 1, "start": "2024-07-02 07:06:47.502664", "stderr": "ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable", "stderr_lines": ["ERROR 1348 (HY000) at line 1: Column 'authentication_string' is not updatable"], "stdout": "", "stdout_lines": []}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật