Sqoop Introduction

Sqoop is useful tool to move data from Relational databases to HDFS and vice versa. In this blog, let us take a look at basics of Sqoop.

One reason which made Hadoop ecosystem popular is its ability to process different forms of data. But not all data is present in HDFS i.e Hadoop Distributed File System. We have been using relational databases to store and process structured data for a long time. That is why a lot of data still resides in RDBMS and we need some tool to bring that data to HDFS. To solve this problem, We can use Sqoop.

What is Sqoop:

Apache Sqoop is an open source tool that helps user transfer data between structured data sources and Hadoop. Using it, we can extract data from RDBMS, load it to Hadoop, process it and again store it back to RDBMS.

Sqoop uses map reduce to import and export data which provides parallel operation. After we submit Sqoop command, it converts that to map reduce job and submits it to Hadoop cluster. Hadoop cluster then executes that job.

Sqoop commands create Java classes which have the structure of data which is being transferred. We can use Java source code and classes which are generated in the same directory from where we invoke Sqoop command.

Sqoop Tools:

We can use the command ‘$sqoop help’ to display the collection of Sqoop tools.

Sqoop tools

We can see all the options and configuration parameters of each tool by using ‘$sqoop  –help’.


We can check connectivity with a relational database or run an ad-hoc query using ‘eval’ tool.

For this, we need to give a JDBC connection URL of the database. Along with that, we also need to provide username and password which will be used to connect to our database. We can use ‘eval’ to list all tables in the employees database which is already present in MySQL.

sqoop eval --connect jdbc:mysql://localhost/employees --username root -P -e 'show tables;'

Here we have used localhost in our connection string that is because MySQL is on the same machine as Sqoop. If our MySQL database resides on another machine we will need to give its address. You can directly give the password in the command line using –password argument but this can be risky in the production environment.

We do have a better way to pass connection string, username, and password. We can store all this information in one file and use that file as an argument in Sqoop command. Consider we have following conf file.

#connection string

#username of database

#password for database

We can rewrite eval command like this using the conf file.

sqoop eval --options-file conf -e 'show databases;'

simple isn’t it?

We have seen what Sqoop is and it’s basic commands. We will explore it in detail in the next few articles in this section.

Leave a Reply

Your email address will not be published. Required fields are marked *