I installed Hive on Windows 10 and I am using Cygwin to use the schemaTool utility in order to initialize metastore, as it is not compatible with the Windows Terminal.
I attempt to run the following command:
$ $HIVE_HOME/bin/schematool -dbType derby -initSchema --verbose
And I am getting the following error:
Metastore connection URL: jdbc:derby://localhost:1527/metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.ClientDriver
Metastore connection User: APP
Starting metastore schema initialization to 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
at org.apache.hadoop.hive.metastore.MetaStoreSchemaInfo.generateInitFileName(MetaStoreSchemaInfo.java:137)
at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:585)
at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:567)
at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1517)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
*** schemaTool failed ***
My Hadoop version is 3.2.0 and my Hive version is 3.1.2.
yeah finally I have solved it no need of Cygwin.
first download these cmds and paste them in bin folder which you might have already done
https://github.com/HadiFadl/Hive-cmd
no need to repeat it if you have already done it :)
i have created the database in mysql by create database metastore_db;
my hive_site.xml looks like this because i choosed to use mysql, write your mysql username,password in place of root root.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3307/metastore_db?createDatabaseIfNotExist=false&useSSL=true</value>
<description>metadata is stored in a MySQL server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>MySQL JDBC driver class</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>user name for connecting to mysql server</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<description>password for connecting to mysql server</description>
</property>
</configuration>
write this in cmd:
hive --service schematool -dbType derby -initSchema
or write this if you are using mysql as backend:
hive --service schematool -dbType mysql -initSchema
if you get output at the end like
Initialization script completed
schemaTool completed
you have successfully done it. else try to go to C:\apache-hive-3.1.2-bin\bin via cmd and then execute it.