Using Hive with MySQL/MariaDB
To set up MySQL or Maria DB for use with Hive:
Steps
On the Ambari Server host, stage the appropriate MySQL connector for later deployment.
Install the connector.
RHEL/CentOS/Oracle Linux
yum install mysql-connector-java*
SLES
zypper install mysql-connector-java*
Debian/Ubuntu
apt-get install libmysql-java
Confirm that
mysql-connector-java.jar
is in the Java share directory.
ls /usr/share/java/mysql-connector-java.jar
Make sure the .jar file has the appropriate permissions - 644.
Execute the following command:
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
Create a user for Hive and grant it permissions.
Using the MySQL database admin utility:
# mysql -u root -p
CREATE USER '<HIVEUSER>'@'localhost' IDENTIFIED BY '<HIVEPASSWORD>';
GRANT ALL PRIVILEGES ON *.* TO '<HIVEUSER>'@'localhost';
CREATE USER '<HIVEUSER>'@'%' IDENTIFIED BY '<HIVEPASSWORD>';
GRANT ALL PRIVILEGES ON *.* TO '<HIVEUSER>'@'%';
CREATE USER '<HIVEUSER>'@'<HIVEMETASTOREFQDN>' IDENTIFIED BY '<HIVEPASSWORD>';
GRANT ALL PRIVILEGES ON *.* TO '<HIVEUSER>'@'<HIVEMETASTOREFQDN>';
FLUSH PRIVILEGES;
Where
<HIVEUSER>
is the Hive user name,<HIVEPASSWORD>
is the Hive user password and<HIVEMETASTOREFQDN>
is the Fully Qualified Domain Name of the Hive Metastore host.
Create the Hive database.
The Hive database must be created before loading the Hive database schema.
# mysql -u root -p
CREATE DATABASE <HIVEDATABASE>
Where
<HIVEDATABASE>
is the Hive database name.