0

I am trying to install a galera cluster (mysql with wsrep 5.7) on a centos 7.7 with ansible.

My rule file:

  - name: Start the MySQL Daemon (first time)
  service:
    name: mysqld
    enabled: yes
    state: started

- name: Parse the logfile for temporary password
  command: grep 'temporary password' /var/log/mysqld.log
  register: pw_line

- name: Register the password
  set_fact:
    tmp_password: "{{ pw_line.stdout | regex_search(regexp, '\\1') }}"
  vars:
    regexp: ': (.+)$'

- name: Change temporary root password
  shell:
    cmd: mysql -u root --password="{{ tmp_password[0] }}" --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '{{ icinga2_mysql_root_password }}'; flush privileges; "

This leads to the following output:

changed: [icinga2-db1.local] => {
    "changed": true,
    "cmd": "mysql -u root --password=\"fJuu)YTIA0<*\" --connect-expired-password -e \"ALTER USER 'root'@'localhost' IDENTIFIED BY 'S0me_P4$.worD'; flush privileges; \"",
    "delta": "0:00:00.021148",
    "end": "2020-02-23 18:23:10.323202",
    "invocation": {
        "module_args": {
            "_raw_params": "mysql -u root --password=\"fJuu)YTIA0<*\" --connect-expired-password -e \"ALTER USER 'root'@'localhost' IDENTIFIED BY 'S0me_P4$.worD'; flush privileges; \"",
            "_uses_shell": true,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2020-02-23 18:23:10.302054",
    "stderr": "mysql: [Warning] Using a password on the command line interface can be insecure.",
    "stderr_lines": [
        "mysql: [Warning] Using a password on the command line interface can be insecure."
    ],
    "stdout": "",
    "stdout_lines": []
}

Which seams fine, but unfortunately, I can't login after. I get the error message:

# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

If I reset (reinstall the system) and login via mysql to the db and execute the query, all works fine.

I tried already a lot of different ways of how I could solve this issue of mine (mysql_user, editing my.cnf, using mysqladmin) but without success.

Can anybody enlighten me please?

EDIT: I tried the following on command line:

# mysql -u root --password="#Uq.L*gcr0k." -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'S0me_P4$.worD'; flush privileges;"

that lead to the same error above. But, this:

# mysql -u root --password="JRyAmO=p_7yq"
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29

Copyright (c) 2000, 2020, 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.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'S0me_P4$.worD'; flush privileges;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql>

Works. Is this a bug in mysql 5.7?

iamcheko
  • 76
  • 2
  • Have you tried to login after manually password change? – Alexander Tolkachev Feb 26 '20 at 08:33
  • Yes i did and it worked for the second (After "But, this:"). But I figured, that the version of MySQL i've been using is kind of aged, so I will use mariadb 10.4, this will save me the installation of Galera since it is already included and I will see if this password change is still a challenge. – iamcheko Feb 26 '20 at 12:13

0 Answers0