Thursday 13 June 2013

Importing data of Mysql table into the Hive

1) Creating Mysql Database;
 
    >create database test;

2) Use the current database

   >use test;

3) create table in the database

   >create table test1 (name text,id int,password text, primary key(id)); 

//note Hive only accept the table which have Primary key so before going to the Importing table in the Hive Table check you table syntax one's


4) Insert data into table;

  >insert into test1 values('test',2,'test');


5) Now we had created the database name of test and table in that database is test2 with fields name text, id  int , password text. After all thing done in the mysql lets move to the Sqoop;

6) Type following command on the terminal :

  $ sqoop import --connect jdbc:mysql://localhost/test --username 'your username' --password 'your password' --table test1 --hive-import

7) In the above command i use database which we had created above name test and table test1 you can you use your database and table then press Enter

8) Now type 'hive' on the terminal:

       $ hive

9) Then type your query see the value in the table :

   select * from test1;


This all steps if you already have your database then start from step 6  :)  

3 comments:

  1. There are lots of information about hadoop have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in big data. Thanks for sharing this.


    Big Data Training Chennai
    Big Data Training
    Big Data Course in Chennai

    ReplyDelete
  2. I was just wondering how I missed this article so far, this is a great piece of content I have ever seen in the entire Internet. Thanks for sharing this worth able information in here and do keep blogging like this.

    Hadoop Training Chennai | Hadoop Training in Chennai | Big Data Course in Chennai

    ReplyDelete