Sunday, October 13, 2013

SQOOP

SQOOP is used for exporting and importing data from database to HDFS.

Connect to MySQL database
$mysql -u root -p
Enter password:
mysql>CREATE DATABASE hadoopdb;
mysql>SHOW DATABASES;
Database
hadoopdb
mysql>USE hadoopdb;
mysql>grant all privileges on hadoopdb.* to '%'@'localhost';
mysql>CREATE TABLE yashTable(id INT, name VARCHAR(64), salary INT);
mysql>INSERT INTO yashTable(111, 'ABC', 9000);
mysql>INSERT INTO yashTable(111, 'XYZ', 10000);
mysql>INSERT INTO yashTable(111, 'IJK', 11000);
mysql>describe yashTable;

Import Command:
$ Sqoop import --connect jdbc:mysql://localhost/hadoopdb \ -- table yashTable -m 1;

Export Command
$ sqoop export -- connect jdbc:mysql://localhost/hadoopdb -m 1 \ --table yashTable --export-dir /user/yash/yashTable/part-m-00000;

No comments:

Post a Comment