Big Data 6 min read

Installing Apache Hive on macOS with Hadoop and MySQL Metastore

This tutorial provides step‑by‑step instructions for installing Hadoop 3.1.1, Homebrew, Hive, and configuring MySQL as Hive's metastore on macOS, including environment variable setup, hive‑site.xml configuration, MySQL connector placement, schema initialization, and verification commands.

IT Xianyu
IT Xianyu
IT Xianyu
Installing Apache Hive on macOS with Hadoop and MySQL Metastore

This guide explains how to install and configure Apache Hive on macOS, including prerequisite installation of Hadoop 3.1.1 and MySQL for the Hive metastore.

First, ensure Homebrew is installed, then run brew install hive to install Hive.

Edit the ~/.bash_profile to add the following lines:

export HIVE_HOME=/usr/local/Cellar/hive/3.1.1</code>
<code>export PATH=$HIVE_HOME/bin:$PATH

Save the file and apply the changes with source ~/.bash_profile. After that, start Hive by typing hive in the terminal.

Create a MySQL database for the metastore: mysql> create database metastore; Then edit hive-site.xml (located in /usr/local/Cellar/hive/3.1.1/libexec/conf) and add the following configuration:

<configuration></code>
<code>  <property></code>
<code>    <name>hive.metastore.local</name></code>
<code>    <value>true</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>javax.jdo.option.ConnectionURL</name></code>
<code>    <value>jdbc:mysql://localhost/metastore</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>javax.jdo.option.ConnectionDriverName</name></code>
<code>    <value>com.mysql.jdbc.Driver</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>javax.jdo.option.ConnectionUserName</name></code>
<code>    <value>root</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>javax.jdo.option.ConnectionPassword</name></code>
<code>    <value>18883171984</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>hive.exec.local.scratchdir</name></code>
<code>    <value>/tmp/hive</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>hive.downloaded.resources.dir</name></code>
<code>    <value>/tmp/hive</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>hive.metastore.warehouse.dir</name></code>
<code>    <value>/user/hive/warehouse</value></code>
<code>  </property></code>
<code>  <property></code>
<code>    <name>hive.server2.logging.operation.log.location</name></code>
<code>    <value>/tmp/hive</value></code>
<code>  </property></code>
<code></configuration>

Download the MySQL connector JAR from the MySQL website, extract it, and copy the JAR file to /usr/local/Cellar/hive/3.1.1/libexec/lib.

Initialize the Hive metastore schema with: schematool -initSchema -dbType mysql If the initialization succeeds, you will see messages such as “Initialization script completed” and “schemaTool completed”.

Finally, verify the Hive installation by running hive and executing show databases;. The output should list the default database and confirm that Hive is operational.

Note: Hive must be able to access the network during operation; running it without network connectivity may cause failures.

Big DataHiveMySQLInstallationmacOSHadoop
IT Xianyu
Written by

IT Xianyu

We share common IT technologies (Java, Web, SQL, etc.) and practical applications of emerging software development techniques. New articles are posted daily. Follow IT Xianyu to stay ahead in tech. The IT Xianyu series is being regularly updated.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.