1. 程式人生 > >搭建Hive遠端模式在初始化Hive的時候報錯Access denied for user 'hiveowner'@'127.0.0.1' (using password: YES)

搭建Hive遠端模式在初始化Hive的時候報錯Access denied for user 'hiveowner'@'127.0.0.1' (using password: YES)

報錯資訊如下:

[[email protected] 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使用者表的許可權

[email protected] 00:30:  [mysql]> select user,host,authentication_string from user;

修改hiveowner使用者的許可權

 [email protected] 02:07:  [mysql]> delete from user where user='hiveowner' and host='%';

[email protected] 02:07:  [mysql]> flush privileges;

[email protected] 02:07:  [mysql]> select user,host,authentication_string from user;

為了可以遠端hiveowner使用者,需要把此使用者改為所有許可權

[email protected] 02:07:  [mysql]> update user set host='%' where user='hiveowner';

[email protected]

02:15:  [mysql]> flush privileges;
[email protected] 02:15:  [mysql]> select user,host,authentication_string from user;


再次初始化hive

[[email protected] conf]# schematool -dbType mysql -initSchema

證明已經初始化成功。

檢視hive-schema-2.3.0.mysql.sql指令碼

[[email protected] apache-hive-2.3.0-bin]# find . -name hive-schema-2.3.0.mysql.sql

進到MySQL資料庫中,檢視在hive資料庫的中初始化生成的表

或者使用Navicat for MySQL工具檢視

通過以上的資訊可以證明初始化成功