While exporting data from HDFS to mysql the target table must exist in the target database.
Please refer below command to transfer data from hdfs to mysql
// Data in file emp_tbl in HDFS
101, abhi, manager, 50000
102, tiwari, preader, 50000
It is mandatory that the table to be exported is created manually and is present in the database from where it has to be exported.
The following query is used to create the table ‘employee’ in mysql command line.
CREATE TABLE employee (
id INT NOT NULL PRIMARY KEY,
The following command is used to export the table data (which is in emp_tbl file on HDFS) to the employee table
sqoop export --connect jdbc:mysql://localhost/dbName --username root -P --table employee --export-dir /emp_tbl
In the above sqoop command emp_tbl is present in HDFS root.
You can verify the export by running select * from employee command.