I have mysql 5.7 installed on my remote syystem.I have to create a new database and a new user access to that database. As it is mysql-community-server 5.7 initially i have to grep password from /var/log/mysqld.log
[root@lamp2 labadmin]# cat /var/log/mysqld.log | grep temporary
2018-01-09T10:57:17.326484Z 1 [Note] A temporary password is generated for
root@localhost: gg%j,opuE3Sm
2018-01-09T10:57:34.471131Z 0 [Note] InnoDB: Creating shared tablespace for
temporary tables
So by using ansible how do i give root access as i cant find any module to use this password.Do i want to create a script for that. I have executed the following play book and got error
- hosts: lamp
remote_user: root
vars:
dbname: wordpressdb
dbuser: wordpressuser
password: REDhat@123
tasks:
- name: installing mysql-python
yum:
name: MySQL-python
state: present
- name: Creating database
mysql_db: name={{ dbname }} state=present
- name: Create db User
mysql_user: name={{ dbuser }} password={{ password }} priv=*.*:ALL
host='localhost' state=present
error:
TASK [Creating database]
*******************************************************
fatal: [52.172.48.12]: FAILED! => {"changed": false, "failed": true, "msg":
"unable to find /root/.my.cnf. Exception message: (1045, \"Access denied
for user 'root'@'localhost' (using password: NO)\")"}
Help me to find a solution.Iam new to ansible.Also i want to know how to reset root password.
Note: i already copied .my.cnf to target containg username and password for mysql login.but i did it manulally.I want to login by using that temporary password at first.How can i make it possible