cd$HIVE_HOME/conf
vim hive-site.xml
设置hive-site.xml内容为,需要自行配置mysql账号密码
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- Put site-specific property overrides in this file. --><configuration><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true</value></property><property><name>javax.jdo.option.ConnectionDriverName</name><value>com.mysql.jdbc.Driver</value></property><property><name>javax.jdo.option.ConnectionUserName</name><value>root</value></property><property><name>javax.jdo.option.ConnectionPassword</name><value>rt123@RT456</value></property></configuration>
如果hive启动很久,则说明mysql的配置有问题
初始化
schematool -dbType mysql -initSchema
如果show tables; 报错
FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
则说明初始化未成功
成功标志 mysql库中多个一个metastore的库,库中有很多表,如PARTITIONxxxx、DBS、TBLS等,并且hive窗口show tables;返回ok show tables正常返回空,因为元数据存储在mysql中