Sqoop with MySQL-part-1

Sqoop with MySQL-part-1

Import data from mysql to hdfs
Loading data from mysql to sqooop

• 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,
https://prwatech.in/online-support/ and put on cloudera desktop .
• Copy mysql connector jar into sqoop using below command.

You can check weather jar file is copied sqoop/lib or not using below command.

To check the ipaddress of your machine open machine command prompt and type below command.

In Mysql command prompt grant all privillagies to ipaddress 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 password –P –target-dir /dirname -m 1

To check output
• Open browser and go to /usr/sqoopOut/part-m-00000

IMPORT DATA FROM MYSQL USING PRIMARY KEY
1. Create Table Test inside database prwatech, where P_id is used as a Primary Key

2. In VMware type the command as given below in the screenshot-

3. Now In the HDFS the file will be displayed as-

Category: SQOOP