Hadoop environment has made our work simpler and we can now insert and work with data effortlessly and quickly.
How about inserting table in Hadoop which already exists in MySQL?
100% Free Course On Big Data Essentials
Subscribe to our blog and get access to this course ABSOLUTELY FREE.
- Installing MySQL
- Creating a table and inserting values
- Installing Sqoop
- Fetching the table within MySQL using Sqoop
There’s only one prerequisite:
Running instance of Hadoop in any Linux OS.
Steps to install MySQL are as follows:
- Open terminal and follow the command below:
sudo yum install mysql-server
2. If it asks for permission, enter yes.
3. Let the download complete.
4. Once the download is completed, we will start MySQL services using the command:
sudo service mysql start
5.Enter the mysql shell as root user with the following command:
mysql -u root
Congratulations!!! MySQL is installed on your Linux machine.
Creating a Table and Inserting Values
- Create a database to work with. The syntax is as follows:
Create database <database name>; use <database name>;
- To create table and insert values inside table, follow the syntax shown below:
create table <table name>(column name1, column name 2); insert into <table name> values(column1 value1, column2 value1); insert into <table name> values(column1 value2, column2 value2);
These commands are compulsory for a local user to have the privileges.
grant all on *.* to '<username>@<hostname>' with grant option; flush privilages; commit; exit;
Steps to install Sqoop are as follows:
- Download Sqoop (1.99.6) from the link:
- Download the highlighted tar file. Extract it and place it in a secure location.
Note: Location should not be altered.
3. Set HOME and PATH inside .bashrc file.
Also, run the following command in the terminal for the changes to be affected.
4.Search for the mysql-connector-java-5.1.21 in Google. Then download and save it within sqoop/lib directory.
5. Come to the terminal to operate Sqoop.
6.Make the changes in .bashrc file with export path for Sqoop home. The path as shown in the image below.
7. This command will confirm that sqoop is recognized by the system.
Congratulations!!! Sqoop is now installed and running on your system.
Fetching the Table Within MySQL Using Sqoop
- The following command will fetch the table created inside MySQL named company:
2. To see the result, use the following command which will allow access to HDFS.
Hope this blog was useful in giving you an insight on Integrating MySQL with Sqoop. Click Here to learn more.