# Mysql DB sync of all tables in DB at once

**URL:** <https://discuss.elastic.co/t/mysql-db-sync-of-all-tables-in-db-at-once/129602>\
**Category:** Elasticsearch\
**Created:** [April 26, 2018, 7:36am UTC](https://discuss.elastic.co/t/mysql-db-sync-of-all-tables-in-db-at-once/129602 "2018-04-26T07:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![raghav1107](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@raghav1107](https://discuss.elastic.co/u/raghav1107)\
**Post date:** [April 26, 2018, 7:36am UTC](https://discuss.elastic.co/t/mysql-db-sync-of-all-tables-in-db-at-once/129602/1 "2018-04-26T07:36:32Z")

</div>

Hi,

We have mysql database which has 10 to 12 tables. Currently we are using log stash conf as below and jdbc plugin to sync the table data into elastic search. some tables has lakhs of records and might take time to sync.

Is there a way to specify all the tables of the DB in the configuration file and any updates/inserts in mysql should also sync elastic search ? Please let me know how to proceed on this.

input {  
jdbc{  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/STARWARS"  
jdbc\_user =\> "root"  
jdbc\_password =\> "starwars"  
jdbc\_driver\_library =\> "/opt/jdk1.5.0\_05/lib/mysql-connector-java-5.0.4-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
statement =\> "select \* from roles"  
}  
}  
output {  
stdout {codec =\> json\_lines}  
elasticsearch {  
"hosts" =\> "localhost:9200"  
"index" =\> "code\_coverage\_net1"  
"user" =\> "elastic"  
"password" =\> "elastic"  
}  
}

Thanks,  
Raghav

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [April 26, 2018, 8:09am UTC](https://discuss.elastic.co/t/mysql-db-sync-of-all-tables-in-db-at-once/129602/2 "2018-04-26T08:09:21Z")

</div>

As explained in the [documentation for the `jdbc` input plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_configuring_multiple_sql_statements), in order to get Logstash to execute multiple statements (one per table), you need to add one `jdbc` input for each statement.

So simply copy/paste the one you have as many times as tables you want to read and change the statement to read from the appropriate tables.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 24, 2018, 8:09am UTC](https://discuss.elastic.co/t/mysql-db-sync-of-all-tables-in-db-at-once/129602/3 "2018-05-24T08:09:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
