Hive与MySQL的集成

1.进入到,/opt/cdh-5.7.6/hive-1.1.0-cdh5.7.6/conf,目录中编辑hive-site.xml文件

2.添加参数:

<!--指定要连接的数据库-->
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://bigdata-training001.hpsk.com:3306/cdhhive?createDatabaseIfNotExist=true</value>
    <description>JDBC connect string for a JDBC metastore</description>
  </property>
<!--数据库驱动-->
  <property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>Driver class name for a JDBC metastore</description>
  </property>
<!--登录数据库的用户名-->
  <property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>root</value>
    <description>Username to use against metastore database</description>
  </property>
<!--登录数据库的密码-->
  <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>123456</value>
    <description>password to use against metastore database</description>
  </property>
<!--显示数据库名称-->
  <property>
    <name>hive.cli.print.current.db</name>
    <value>true</value>
    <description>Whether to include the current database in the Hive prompt.</description>
  </property>

3.将MySQL连接驱动放入hive的lib目录,cp /opt/tools/mysql-connector-java-5.1.27-bin.jar lib/

4.完成启动,bin/hive

posted on 2017-09-18 12:18  任性的大萝卜  阅读(115)  评论(0编辑  收藏  举报

导航