报错信息如下:
[root@bigdata11 conf]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/training/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/training/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL: jdbc:mysql://localhost:3306/hive?useSSL=false
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: hiveowner
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: java.sql.SQLException : Access denied for user 'hiveowner'@'127.0.0.1' (using password: YES)
SQL Error code: 1045
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
根据报错信息可以看出时权限的问题
Access denied for user 'hiveowner'@'127.0.0.1' (using password: YES)
SQL Error code: 1045
查看MySQL用户表的权限
root@db 00:30: [mysql]> select user,host,authentication_string from user;
修改hiveowner用户的权限
root@db 02:07: [mysql]> delete from user where user='hiveowner' and host='%';
root@db 02:07: [mysql]> flush privileges;
root@db 02:07: [mysql]> select user,host,authentication_string from user;
为了可以远程hiveowner用户,需要把此用户改为所有权限
root@db 02:07: [mysql]> update user set host='%' where user='hiveowner';
root@db 02:15: [mysql]> flush privileges;
root@db 02:15: [mysql]> select user,host,authentication_string from user;
再次初始化hive
[root@bigdata11 conf]# schematool -dbType mysql -initSchema
证明已经初始化成功。
查看hive-schema-2.3.0.mysql.sql脚本
[root@bigdata11 apache-hive-2.3.0-bin]# find . -name hive-schema-2.3.0.mysql.sql
进到MySQL数据库中,查看在hive数据库的中初始化生成的表
或者使用Navicat for MySQL工具查看
通过以上的信息可以证明初始化成功
欢迎大佬们扫下面二维码关注我个人微信公众号(Java大数据架构师成长之路)