How to create MySQL tables using Ansible?

0 votes
How to create MySQL tables using Ansible?
Feb 4 in Ansible by Anvit
515 views

2 answers to this question.

0 votes

Hey @Anvit, you can use a module called mysql_db to add or remove databases from a remote host.

And then you can just copy all the create statement into a single file and import it. 

something like this:

- mysql_db: name=my_db state=import target=/tmp/dump.sql.bz

answered Feb 4 by Diana
0 votes
---

- hosts: dbserver

  tasks:

   - name: create a table in mysqlDB

     command: mysql -u username -p yourpassword -h yourhostname dbname --skip-column-names --execute "create table if not exist tablename (name INT AUTO_INCREMENT, title VARCHAR(255) NOT NULL"
answered Mar 19 by Ankit Tyagi
Thanks @Ankit

Related Questions In Ansible

0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,620 points
72 views
0 votes
1 answer

How can I create a new user using ansible ploybook?

You're switching from the root user. Root ...READ MORE

answered Mar 29, 2018 in Ansible by DareDev
• 6,810 points
86 views
0 votes
1 answer

How to remove cron using Ansible

Hey @Likhit, You could use something like ...READ MORE

answered Jan 28 in Ansible by Kavya
195 views
0 votes
1 answer

How to encrypt and existing file using Ansible Vault?

Hey @Kyraa, to encrypt an existing file ...READ MORE

answered Jan 29 in Ansible by Kavya
233 views
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer