本文介紹了無法更改 root 帳戶 ansible 的密碼的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我有以下錯誤:
{"failed": true, "invocation": {"module_args":
{"append_privs": false, "check_implicit_admin": true, "config_file": "/root/.my.cnf", "connect_timeout": 30, "encrypted": false, "host": "rothko", "host_all": false, "login_host": "localhost", "login_password": "", "login_port": 3306, "login_unix_socket": null, "login_user": "root", "name": "root", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "priv": "*.*:ALL,GRANT", "sql_log_bin": true, "ssl_ca": null, "ssl_cert": null, "ssl_key": null, "state": "present", "update_password": "always", "user": "root"}, "module_name": "mysql_user"},
"item": "rothko",
"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: NO)\")"}
這些是我的劇本說明和我嘗試過的內容:
These are my playbook instructions and what I've tried:
# - name: Create .my.cnf file with root password credentials
# become: yes
# template: src=".my.cnf.j2" dest="/root/.my.cnf" owner=root group=root mode=0600
# - name: Restart mysql
# service: name=mysqld state=restarted
# - name: Change root user password on first run
# mysql_user:
# name=root
# host=localhost
# password={{ mysql_root_password }}
# priv=*.*:ALL,GRANT
- name: update mysql root password for all root accounts
become: yes
mysql_user:
login_user=root
login_password=''
name=root
host="{{ item }}"
password="{{ mysql_root_password }}"
check_implicit_admin=yes
priv="*.*:ALL,GRANT"
with_items:
- "{{ ansible_hostname }}"
- 127.0.0.1
- ::1
- localhost
ignore_errors: true
這是一個眾所周知的問題,我發現了一些可以解決它的問題,但沒有解決方案:
This is a well known problem and I 've found a few questions that treat it but there was no solution for me:
- 1
- 2
- 3
推薦答案
這里有更多信息:在 Centos7 上更改 mysql root 密碼
我嘗試做一些有意義的事情
I try to do some ansible stuff
- 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('toto') 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
希望能幫到你
這篇關于無法更改 root 帳戶 ansible 的密碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!