Use Sqoop in CentOS 5.6 to import and export hive data to MySQL

Source: Internet
Author: User

Running Environment CentOS 5.6 Hadoop hive

Sqoop is a tool developed by clouder for hadoop technology support to import and export data between relational databases, hdfs, and hive.

Read more: Sqoop configuration and installation

1. Install sqoop first. If you are using the clouder distribution version, it will be very simple.

# Yum install sqoop

If the official version is used

# Cd/etc/yum. repos. d

# Wget http://archive.cloudera.com/RedHat/cdh/cloudera-cdh3.repo

# Yum-y install sqoop

Sqoop installation is complete.

2. Use sqoop

First copy the mysql-connector-java-5.1.16-bin.jar file to the/usr/lib/sqoop/lib folder

List all database commands in the mysql database

# Sqoop list-databases -- connect jdbc: mysql: // localhost: 3306/-- username root -- password 123456

Connect to mysql and List table commands in the database

# Sqoop list-tables -- connect jdbc: mysql: // localhost: 3306/test -- username root -- password 123456

In the command, test is the name of the test Database in mysql database, username password is the user password of mysql database respectively.


Copy the table structure of relational data to hive
Sqoop create-hive-table -- connect jdbc: mysql: // localhost: 3306/test -- table username -- username root -- password 123456 -- hive-table test
Here, -- table username is the table in database test in mysql -- hive-table test is the name of the table created in hive.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.