Unable to change password for root account ansible(无法更改 root 帐户 ansible 的密码)
本文介绍了无法更改 root 帐户 ansible 的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下错误:
{"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 的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:无法更改 root 帐户 ansible 的密码
基础教程推荐
猜你喜欢
- SQL Server 2016更改对象所有者 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01