Sqoop --target-dir example

Example for Import using Sqoop in target directory in the HDFS

$ sqoop-import --connect jdbc:mysql://localhost:3306/sqoop --username root --password root --table Employee_Table --target-dir employeeImportAll --m 1

The above command will import the data present in Employee_Table in sqoop database to the directory named employeeImportAll directory


After import is done we can check if data is present

Just see the output for each of the 3 commands one by one.

hadoop@jj-VirtualBox:~$ hadoop fs -ls
hadoop@jj-VirtualBox:~$ hadoop fs -ls /user/hadoop/employeeImportAll
hadoop@jj-VirtualBox:~$ hadoop fs -cat /user/hadoop/employeeImportAll/part-m-00000


All the results are present as comma separated file

1 comment:

  1. i have successfully imported mysql table using sqoop as far as the success message is concerned but now the problem is that i cannot show the tables using the "show tables; " command in hive it gives me the following error

    hive> show tables;
    FAILED: Error in metadata: javax.jdo.JDOFatalInternalException: Error creating transactional connection factory
    NestedThrowables:
    java.lang.reflect.InvocationTargetException
    FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask



    please help me find out the problem

    ReplyDelete

Please share your views and comments below.

Thank You.