这是个很坑的问题
异常信息:
[root@kdg01 bin]# schematool -initSchema -dbType mysql
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/tmp/myshell:/root/myshell:/usr/mysoft/jdk1.8.0_111/bin:/usr/mysoft/jdk1.8.0_111/bin:/usr/mysoft/hadoop-2.6.5/bin:/usr/mysoft/hadoop-2.6.5/sbin:/usr/local/mysql/bin:/kdg/hive2/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/kdg/hive2/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/mysoft/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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://192.168.200.10:3306/hive_class?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: mysql
org.apache.hadoop.hive.metastore.HiveMetaException:Failed to get schema version.
Underlying cause: java.sql.SQLException : Access denied for user 'mysql'@'kdg01' (using password: YES)
SQL Error code: 1045
Use --verbose for detailed stacktrace.
*** schemaTool failed***
原因:
密码错误。用这个账号和密码登录mysql能够登录,但是当用schematool对mysql进行初始化的时候却出错。原因就在于mysql的安装。。。。利用hive初始化数据库的时候是随机找的,可能找到的是没有密码,和hive-site.xml文件中的配置不匹配,导致出错。这个mysql是用来装元数据的。
问题解决
最终问题解决:把数据库里面的不是%的数据全部删除【确保hive-site.xml中配置正确的前提下】
注: '%'表示全部用户
现象描述:
Hive本地模式schematool无法初始化mysql数据库。
mysql -uroot -p1 【希望用谁关联hive就用谁登陆】
select host from user;
delete from user where host<>'%';
select host from user;
exit
service mysqld restart
schematool -initSchema -dbType mysql