Import and Export Data with Sqoop in HDFS
Import and export data with Sqoop in HDFS, Welcome to the world of advanced Tutorials on Hadoop technology. Are you looking forward to How to Import Data from MySQL to HDFS using sqoop? Or looking for some help on import and export data from mysql to hdfs using sqoop? Then you’ve landed on the Right Path which providing advanced tutorial based concepts on the Hadoop HDFS. In this tutorial, one can easily explore How to Import and export data with Sqoop in HDFS with step by step explanation.
When working with Big Data in Hadoop, a very useful command line tool is Apache Sqoop which allows us to import data from MySQL database into HDFS, as well as to export data in HDFS to MySQL databases using Sqoop. There are many possible ways to Import and export data with Sqoop in HDFS, just follow the below-mentioned step by step process of How to import and export data from MySQL to HDFS using Sqoop tutorials which was originally designed by India’s Leading Hadoop Training institute Professionals who also offering advanced Hadoop Course and Certification Programs.
Import data from MySQL to HDFS using Sqoop
Install mysql on your machine,open terminal after open the terminal it asking for password enter password as root.
Create database by using below command.
Use your created database use below command.
Create table .
Insert values into created table.
If you want to see the inserted data use below query.
Go to below link and download mysql-connector-java-5.1.26-bin.jar, link and put on cloudera desktop .
Copy mysql connector jar into sqoop using below command.
Password is cloudera
You can check weather jar file is copied sqoop/lib or not using below command.
To check the IP address of your machine open machine command prompt and type below command.
In MySQL command prompt grant all privileges to IP address of VMnet1 by using below command.
Import data from mysql to sqoop
Using below syntax : Sqoop/bin$ sqoop import –connect jdbc:mysql:ipaddress/databasename
–table <tablename> –username <username of mysql> –P –target-dir /dirname -m 1
To check output : Open browser and go to /usr/sqoopOut/part-m-00000
Export Data from HDFS to MySQL using Sqoop
Create table in mysql
Use below command for export data from hdfs to mysql
Syntax: Sqoop/bin$ sqoop export –connect jdbc://ipaddress/databasename –username username –password password –table tablename –export-dir /dirname
To check data where data exported use below query