hive修改默认元数据存储数据库derby改为mysql

进入mysql

mysql -uroot -p //默认没有密码

为hive建立相应的用户以及密码

 CREATE USER 'hive' IDENTIFIED BY 'mysql';

授权hive用户访问权限

 GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%' WITH GRANT OPTION;

创建hive数据库

mysql -uhive -pmysql//以hive用户进入mysql
create database hive;

将mysql的jdbc驱动放置到hive的lib目录下

wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.11.tar.gz/from/http://mysql.he.net/
tar -xvzf mysql-connector-java-5.1.11.tar.gz
cp mysql-connector-java-5.1.11/*.jar $HIVE_HOME/lib

接下来配置hive.site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
    <property>
        <name>hive.metastore.local</name>
        <value>true</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hive?characterEncoding=UTF-8</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionDriverName</name>
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive</value>
    </property>
    <property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>mysql</value>
    </property>
</configuration>

修改为mysql

schematool -initSchema -dbType mysql

遇到的问题:

Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'hive'@'localhost' (using password: YES)

这是由于我们设置的时候允许全网段的访问,忽略了localhost

可以这样改(为其添加一个localhost):

grant all privileges on *.* to hive@localhost identified by 'pass' with grant option;
展开阅读全文

没有更多推荐了,返回首页