How to create MySQL tables using Ansible?

0 votes
How to create MySQL tables using Ansible?
Feb 4 in Ansible by Anvit
1,319 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
M using same command :

    command: mysql -u root -p ********** bobdata --skip-column-names --execute "create table test789 (Name VARCHAR(25),ID int)"

But its giving syntax error . Kindly assist.

Hey @Shubhi, "int" should be in caps. Change the command to the following:

mysql -u root -p ********** bobdata --skip-column-names --execute "create table test789 (Name VARCHAR(25),ID INT)"

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
134 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
134 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
444 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
596 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
218 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer