# How do i import data from mysql to elastic search 1.6

**URL:** <https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658>\
**Category:** Elasticsearch\
**Created:** [June 15, 2015, 4:49am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658 "2015-06-15T04:49:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_Kumar](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Deepak\_Kumar](https://discuss.elastic.co/u/Deepak_Kumar)\
**Post date:** [June 15, 2015, 4:49am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/1 "2015-06-15T04:49:54Z")

</div>

How do i import data from mysql to elastic search 1.6 as river is depriciated.  
and also suggest method to update elastic search real time

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2015, 4:56am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/2 "2015-06-15T04:56:55Z")

</div>

Have a look in [Is jdbc river is going to expire? If yes then what is the alternative to connect the database](https://discuss.elastic.co/t/is-jdbc-river-is-going-to-expire-if-yes-then-what-is-the-alternative-to-connect-the-database/497)

---

<div class="post-metadata">

**Author:** ![Deepak\_Kumar](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Deepak\_Kumar](https://discuss.elastic.co/u/Deepak_Kumar)\
**Post date:** [June 15, 2015, 5:11am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/3 "2015-06-15T05:11:04Z")

</div>

hey mark thanks for reply, but that thread is not solving the problem for es 1.6

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 15, 2015, 5:51am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/4 "2015-06-15T05:51:01Z")

</div>

It's the exact same problem.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [June 15, 2015, 7:45am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/5 "2015-06-15T07:45:02Z")

</div>

Have you tried [https://github.com/jprante/elasticsearch-jdbc](https://github.com/jprante/elasticsearch-jdbc) ?

---

<div class="post-metadata">

**Author:** ![Deepak\_Kumar](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Deepak\_Kumar](https://discuss.elastic.co/u/Deepak_Kumar)\
**Post date:** [June 15, 2015, 7:58am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/6 "2015-06-15T07:58:43Z")

</div>

hey jprante,  
I tried JDBC importer its giving me error ,  
getting Error: Could not find or load main class org.xbib.tools.Runner.

actually documentation for this importer is difficult to understand for newbie

---

<div class="post-metadata">

**Author:** ![Mohit\_Kumar\_Yadav](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mohit\_Kumar\_Yadav](https://discuss.elastic.co/u/Mohit_Kumar_Yadav)\
**Post date:** [June 23, 2015, 8:15am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/7 "2015-06-23T08:15:55Z")

</div>

Hi Deepak/jprante  
I am also facing same issue. Have found any solution for that.

---

<div class="post-metadata">

**Author:** ![sohilelasticsearch](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sohilelasticsearch](https://discuss.elastic.co/u/sohilelasticsearch)\
**Post date:** [June 24, 2015, 5:33pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/8 "2015-06-24T17:33:29Z")

</div>

Hi @Mohit_Kumar_Yadav ,

I have tried the steps mentioned by @jprante and it's working fine.

---

<div class="post-metadata">

**Author:** ![sohilelasticsearch](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sohilelasticsearch](https://discuss.elastic.co/u/sohilelasticsearch)\
**Post date:** [June 24, 2015, 5:48pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/9 "2015-06-24T17:48:25Z")

</div>

Hi @Mohit_Kumar_Yadav,

If you are using [https://github.com/jprante/elasticsearch-jdbc](https://github.com/jprante/elasticsearch-jdbc) link then follow below steps  
Step 1 \> Say you download elasticsearch-jdbc in **/opt/elasticsearch-jdbc-1.6.0.0**  
Step 2 \> set **lib** and **bin** variables  
e.g  
[root@L123]# lib=/opt/elasticsearch-jdbc-1.6.0.0/lib  
[root@L123]# bin=/opt/elasticsearch-jdbc-1.6.0.0/bin

Step 3 \> Now fetch data from mysql and insert into ES.  
for e.g

[root@L123]#echo '{  
"type" : "jdbc",  
"jdbc": {  
"url":"jdbc:mysql://localhost:3306/ABC",  
"user":"XXX",  
"password":"XXXXXX",  
"sql":"select id as "\_id", p\_id as "pid" ,s\_id as "sid" from tmp",  
"index" : "myindex",  
"type" : "mytype"  
}  
}' | java -cp "${lib}/\*" -Dlog4j.configurationFile=${bin}/log4j2.xml org.xbib.tools.Runner org.xbib.tools.JDBCImporter

I hope this will help you.

---

<div class="post-metadata">

**Author:** ![Mohit\_Kumar\_Yadav](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Mohit\_Kumar\_Yadav](https://discuss.elastic.co/u/Mohit_Kumar_Yadav)\
**Post date:** [June 25, 2015, 7:30pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/10 "2015-06-25T19:30:47Z")

</div>

Hi sohil,  
Thanks for replying..  
I am also following the steps of the jprante. But i am facing this issue  
"Error: Could not find or load main class org.xbib.tools.Runner" whenever I  
start the batch script.

System details:-  
Elastic- 1.6  
Database- oracle db  
OS- windows seven

Thanks in advance

Regards  
Mohit  
On 24-Jun-2015 11:13 pm, "sohilelasticsearch" [noreply@discuss.elastic.co](mailto:noreply@discuss.elastic.co)  
wrote:

---

<div class="post-metadata">

**Author:** ![RanjitShinde91](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@RanjitShinde91](https://discuss.elastic.co/u/RanjitShinde91)\
**Post date:** [June 30, 2015, 2:02pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/11 "2015-06-30T14:02:57Z")

</div>

Does anybody able to resolve "Error: Could not find or load main class org.xbib.tools.Runner" issue on windows machine?  
I am facing the same issue.  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [June 30, 2015, 2:51pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/12 "2015-06-30T14:51:30Z")

</div>

Hey, I can not test JDBC importer on Windows.

Community support for Windows is very welcome!

---

<div class="post-metadata">

**Author:** ![Edouard\_Kombo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/edouard_kombo/32/3667_2.png) [@Edouard\_Kombo](https://discuss.elastic.co/u/Edouard_Kombo)\
**Post date:** [July 12, 2015, 4:57pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/13 "2015-07-12T16:57:33Z")

</div>

It's giving the same error on Linux.  
I'm stucked since 3 days with this issue, I am on a Debian distribution.

---

<div class="post-metadata">

**Author:** ![sohilelasticsearch](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@sohilelasticsearch](https://discuss.elastic.co/u/sohilelasticsearch)\
**Post date:** [July 13, 2015, 1:14pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/14 "2015-07-13T13:14:32Z")

</div>

Hi Edouard\_Kombo,

Before executing below command  
**java -cp "${lib}/\*" -Dlog4j.configurationFile=${bin}/log4j2.xml org.xbib.tools.Runner org.xbib.tools.JDBCImporter**

first print the value of **lib** and **bin** variables.  
e.g  
[root@L123]# echo $bin  
[root@L123]# echo $lib  
If both variables pointing to correct path then it will work.

Thanks,  
Sohil Raghwani

---

<div class="post-metadata">

**Author:** ![MrReda](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@MrReda](https://discuss.elastic.co/u/MrReda)\
**Post date:** [July 23, 2015, 8:00am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/16 "2015-07-23T08:00:32Z")

</div>

I found out the solution ,for windows users please follow the same steps i did to make it work

I'm using elastic search 1.6.0

ES jdbc importer C:\elasticsearch-jdbc-1.6.0.0\ .Tip avoid spaces in the path

download cygwin for windows 7

Mysql database which has data to be imported inside Elastic Search

Once cygwin has been installed change the working directory to :

/cygdrive/c/elasticsearch-jdbc-1.6.0.0/lib

After that ,configure the following script to import the data from mysql to ES like the following :

DIR="$( cd "$( dirname "${BASH\_SOURCE[0]}" )" && pwd )"

bin=${DIR}/bin

lib=${DIR}/lib

echo $lib

echo $bin

echo '{

"type" : "jdbc",

"jdbc" : {

"driver": "com.mysql.jdbc.Driver",

"url" : "jdbc:mysql://localhost:3306/world",

"user" : "root",

"password" : "root",

"sql" : "select \* from city",

"treat\_binary\_as\_string" : true,

```
    "elasticsearch" : {

        "cluster" : "elasticsearch",

        "host" : "localhost",

        "port" : 9300

    },

    "max_bulk_actions" : 20000,

    "max_concurrent_bulk_requests" : 10,

    "index" : "my_index",

"type":"my_type"

```

}

}

' | java \

-cp "elasticsearch-jdbc-1.6.0.0-uberjar.jar;mysql-connector-java-5.1.33.jar" \

-Dlog4j.configurationFile="file://localhost/C:/elasticsearch-jdbc-1.6.0.0/bin/log4j2.xml" \

org.xbib.tools.Runner \

org.xbib.tools.JDBCImporter

Press enter to run and here you go all is done .Check now the data has  
been imported successfully inside elastic search within your index.

Thanks

MrReda

---

<div class="post-metadata">

**Author:** ![ramaa](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@ramaa](https://discuss.elastic.co/u/ramaa)\
**Post date:** [August 20, 2015, 5:07am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/17 "2015-08-20T05:07:39Z")

</div>

@MrReda Can you make the steps clear right from the following step ?  
Or send your blog link where you might have written clearly..  
After that ,configure the following script to import the data from mysql to ES like the following :

---

<div class="post-metadata">

**Author:** ![vankimchau](https://avatars.discourse-cdn.com/v4/letter/v/7ea924/32.png) [@vankimchau](https://discuss.elastic.co/u/vankimchau)\
**Post date:** [August 22, 2015, 4:35am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/18 "2015-08-22T04:35:50Z")

</div>

Hi MrReda,

Can you represent step by step about "how to import data from mysql to ES"on windows? I think it's difficult problems!

Thank in advance!

---

<div class="post-metadata">

**Author:** ![MrReda](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@MrReda](https://discuss.elastic.co/u/MrReda)\
**Post date:** [August 23, 2015, 12:45pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/19 "2015-08-23T12:45:30Z")

</div>

Hi ramaaRamadhevi Rk ,please tell what issue are you facing with ,cause i have already detailed the full required steps to make it happen.

Thanks  
MrReda

---

<div class="post-metadata">

**Author:** ![MrReda](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@MrReda](https://discuss.elastic.co/u/MrReda)\
**Post date:** [August 23, 2015, 12:48pm UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/20 "2015-08-23T12:48:17Z")

</div>

Hi vankimchau have you checked above my comments cause i have already detailed the full required steps.If you are still stuck on it let me know the issue and i will help u with pleasure.

Thanks  
MrReda

---

<div class="post-metadata">

**Author:** ![vankimchau](https://avatars.discourse-cdn.com/v4/letter/v/7ea924/32.png) [@vankimchau](https://discuss.elastic.co/u/vankimchau)\
**Post date:** [August 24, 2015, 2:17am UTC](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658/21 "2015-08-24T02:17:09Z")

</div>

Good day, MrReda!  
Yes, I looking for two problem,  
1, how to change the working directory. for my data on disk:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/1/182e424186e02df420a11be7848a32147df0cbff.png)

2, where is script file that import data from mysql to ES.

Thank in advance!

[Next page](https://discuss.elastic.co/t/how-do-i-import-data-from-mysql-to-elastic-search-1-6/2658.md?page=2)
