Hive is a data warehouse tool based on Hadoop for data extraction, transformation, and loading. This is a mechanism that can store, query, and analyze large-scale data stored in Hadoop. In this article, I will take you through how to Install Hive on Mac with Homebrew using Terminal.

Install Hive on Mac

The installation of Hadoop is divided into these steps:

  1. HDFS (Hadoop) setup : This step is need to completed first place before Hive installation. Please follow the steps to perform the installation.
  2. Hive Installation 
  3. Setup Hive & Mysql Environment Variables
  4. Setup Mysql / Derby database: Hive need this database (called Metastore)  to store the Hive metadata. 
  5. Download the MySQL driver package
  6. Hive  Configuration
  7. Initialize the metadata database
  8. Start Metastore service
  9. Run Hive

Install Hive 

Install Hive with below command

$ brew install hive

Setup Hive & Mysql Environment Variables

Enter vim ~/.bash_profile in the terminal to configure the hive path statement in the blank line.

## HIVE env variables
export HIVE_HOME=/usr/local/Cellar/hive/3.1.2_3/libexec
export PATH=$PATH:/$HIVE_HOME/bin

export PATH=$PATH:/usr/local/mysql-8.0.12-macos10.13-x86_64/bin

Setup Mysql database

Download Mysql database by going to the following Mysql site. After installing the Mysql follow the next steps to initialize the metadata database.


  1. Log in to Mysql: $ mysql -u root -p
  2. Create a database: CREATE database metastore;
  3. $ Source /usr/local/Cellar/hive/3.1.2_3/libexec/scripts/metastore/upgrade/mysql/hive-schema-3.1.0.mysql.sql
  4. CREATE a new user: $ CREATE user ‘hive’@’localhost’ identified by ‘password123’;
  5. Modify user permissions: $ GRANT ALL PRIVILEGES ON  *.* to ‘hive’@’localhost’;
  6. Refresh privileges: FLUSH PRIVILEGES;

Download the MySQL driver package

  1. Open the MySQL official websit
  2. Select Platform Independent -> Download to your machine
  3. Unzip -> Place the jar “mysql-connector-java-8.0.19.jar”  into the /usr/local/Cellar/hive/3.1.2_3/libexec/lib directory

Setup Hive Configuration

Create a file named “hive-site.xml” in the following locations /usr/local/Cellar/hive/3.1.2_3/libexec/conf directory. Please note this file does not exist and needs to be created manually.


Initialize the metadata database

cd /usr/local/Cellar/hive/3.1.2_3/libexec/bin
schematool -initSchema -dbType mysql

Start Metastore service

./hive --service metastore &

Run Hive

Enter the hive command directly in the terminal

hive> show databases;
Time taken: 0.248 seconds, Fetched: 2 row(s)

Related Online Courses

1. Online Courses – Hands-On Hadoop

What you’ll get from it: This course provides hands-on Hadoop with MapReduce, HDFS, Spark, Flink, Hive, HBase, MongoDB, Cassandra, Kafka, etc.

Udemy Offers 2021