Apache Hive Installation – Install Hive on Ubuntu in 5 Min

Keeping you updated with latest technology trends, Join DataFlair on Telegram

1. Objective

This Apache Hive installation tutorial contains simple steps for installing and running hive on Ubuntu only in 5 min. Hive is a data warehousing infrastructure on the top of Hadoop. Moreover, this Apache Hive installation, help in the quick start, setup and configure Hive and run several Hive QL queries to learn the concepts of the Hive.
So, let’s start Apache Hive Installation Tutorial.

Apache Hive Installation

Apache Hive Installation

2. What is Apache Hive?

Apache Hive is a warehouse infrastructure designed on top of Hadoop for providing information summarization, query, and ad-hoc analysis. Hence, in order to get your Hive running successfully, Java and Hadoop ought to be pre-installed and should be functioning well on your Linux OS. For installation procedure in Java and Hadoop, you can refer Hadoop installation Guide

If these professionals can make a switch to Big Data, so can you:
Rahul Doddamani Story - DataFlair
Rahul Doddamani
Java → Big Data Consultant, JDA
Follow on
Mritunjay Singh Success Story - DataFlair
Mritunjay Singh
PeopleSoft → Big Data Architect, Hexaware
Follow on
Rahul Doddamani Success Story - DataFlair
Rahul Doddamani
Big Data Consultant, JDA
Follow on
I got placed, scored 100% hike, and transformed my career with DataFlair
Enroll now
Richa Tandon Success Story - DataFlair
Richa Tandon
Support → Big Data Engineer, IBM
Follow on
DataFlair Web Services
You could be next!
Enroll now

3. Apache Hive Installation on Ubuntu

Now in order to get Apache Hive installation successfully on your Ubuntu system, please follow the below steps and execute them on your Linux OS:

a. Hive Download

In this Apache Hive Installation tutorial, we will use hive-0.13.1-cdh5.3.2. (you can also use any latest version of hive) Download hive using below mentioned link: http://archive.cloudera.com/cdh5/cdh/5/hive-0.13.1-cdh5.3.2.tar.gz This file gets downloaded to your Downloads directory.
After the successful Hive download, we will get the following response:
apache-hive-0.13.1-cdh5.3.2 hive-0.13.1-cdh5.3.2.tar.gz
i. Untar the file
Move the setup file in home directory and untar/unzip the downloaded file by executing the below command:
$ tar zxvf hive-0.13.1-cdh5.3.2.tar.gz

b. Setting up Hive Environment Variables

i. Editing .bashrc file
In order to set up the Hive environment, we need to append the following lines at the end of the ~/.bashrc file.

export PATH=$PATH:$HIVE_HOME/bin
export HADOOP_HOME=/home/dataflair/hadoop-2.6.0-cdh5.5.1
export HIVE_HOME=/home/dataflair/hive-0.13.1-cdh5.3.2

Note: Here enter correct name & version of your hive and correct path of your Hive File “/home/dataflair/hive-0.13.1-cdh5.3.2” this is the path of my Hive File and “hive-0.13.1-cdh5.3.2” is the name of my hive file. So please enter correct path and name of your Hive file. After adding save this file.
And in order to execute this file use the following command:
$ source ~/.bashrc

4. Launching HIVE

This code will help to launch Hive for Apache Hive installation on Ubuntu.
$ hive
The following output gets displayed:

Logging initialized using configuration in jar:file:/home/dataflair/HADOOP/hive-0.13.1-cdh5.3.2/lib/hive-common-0.13.1-cdh5.3.2.jar!/hive-log4j.properties

5. Exit from Hive

When your Apache Hive Installation on Ubuntu will complete, you get this kind of Message.
hive> exit;
Congratulations!! Hive gets successfully installed on your system. Now you can easily execute your commands.
Before using hive you should change the meta-store layer of the hive, follow this tutorial to change meta-store of the hive from derby to MySQL.

6. Hive Queries

Below are some basic Hive queries which you will need while using Apache Hive Installation on Ubuntu.

Hive Queries

Apache Hive Installation

a. Show Databases

This Hive query gives a list of databases which are present in your Hive. If you had newly installed Hive and had not created any database, then by default a database named “default” is present there and would be shown up after executing above query.
show databases;
show databases;

b. Create Database

This will create a new database named “test”. And you can check this database by writing “show databases;” query.
create database_name;
create database test;

c. Use

USE query is used to use the database created by you.
USE database_name;
USE test;

d. Current Database

It is used to know the name of the database in which you are currently working.
set hive.cli.print.current.db=true;


DROP query is used to delete a database
DROP database database_name;
DROP database test1;

f. Create Table

Hadoop Quiz

This command is used to create a new table.

COMMENT ‘Employee details’

create table employee ( Name String comment ‘Employee Name’, Id int, MobileNumber String, Salary Float) row format delimited fields terminated by ‘,’ lines terminated by ‘\n’ stored as textfile;

g. View Tables

It will list you all the tables created by you in the current directory.
show tables;

h. Alter Table

It is used to change attributes inside a table.
Syntax: We can change a number of attributes inside a table what we want to change.

ALTER TABLE TableName RENAME TO new_name
ALTER TABLE TableName ADD COLUMNS (col_spec[, col_spec ...])
ALTER TABLE TableName DROP [COLUMN] column_name
ALTER TABLE TableName CHANGE column_name new_name new_type
ALTER TABLE TableName REPLACE COLUMNS (col_spec[, col_spec ...])

ALTER TABLE employee RENAME TO demo1;

i. Describe table

This command gives a description of the parameters inside the table.
desc TableName;

desc employee;

j. Load Data

This command loads the data from your file path to the selected table created by you in Hive.
LOAD DATA LOCAL INPATH 'Path of the File' OVERWRITE INTO TABLE 'Name of the Table';
LOAD DATA LOCAL INPATH '/home/dataflair/Desktop/details.txt' OVERWRITE INTO TABLE employee;

So, this was all in Hive Installation tutorial. Hope you like our explanation.

7. Conclusion – Hive Installation

Hence, in this Hive installation tutorial, we discussed the process to install Hive on Ubuntu, Windows, and Mac. Moreover, we saw the meaning of Hive. Also, we discussed the launching and exit of Hive. At last, we learned about Hive Queries. Still, if you have any confusion related to Hive Installation, ask in the comment tab.

Reference for Hive

5 Responses

  1. system admin tips says:

    Normally I don’t learn article on blogs, but I
    would like to say that this write-up very forced me to try and do so!
    Your writing taste has been amazed me. Thanks, quite nice article.

    • Data Flair says:

      It is the honest feedback on “Apache HIve Installation” from readers like you that keeps us striving to be better than we were yesterday.
      We are glad we could do our part to change your mind about written material.

  2. Sanjay says:

    Hi, the hive download link is broken.

    • Data Flair says:

      Hi Sanjay,
      Thanks for Commenting on “Apache Hive Installation”. We reviewed the link, it seems fine. Check your Internet connectivity or try opening it on a different device, still you face any problem do let us know.

  3. Santhosh says:

    what does ad-hoc analysis mean ?

    Thanks in advance!!


Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.