How to update or drop a Hive Partition?
December 16, 2020What is the difference between repartition and coalesce in Spark?
December 21, 2020So you were installing Hive and ran into the below issue when Hive was trying to set up the metastore database.
Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for mysql)
Solution
Metastore database in Hive is used to store definitions of your Hive databases and tables. Sometimes the metastore initialization fails because of a configuration issue. The most common issue that we have seen is that the JDBC URL to the database wasn’t correct or the user provided doesn’t have the correct information. Make sure to check the logs and if there are any specific issues related to URL or permissions issues fix them first.
Since you are installing Hive the metastore won’t have any information that you need to worry about. Follow the below steps if you are doing a fresh installation. Don’t try this on an existing metastore which already has metadata about your databases and tables.
- The error suggest you to run ./schematool -initSchema but it will not work when a metastore directory is present already.
- If the metastore directory is present in your Hive installation directory. Rename the directory.
- mv metastore_db metastore_db.bkup
- Run the below command after step 2. Make sure to update the database
- schematool -initSchema -dbType derby
- Check the logs and the issue should be resolved now.