[root@apm-cdh03 ~]# beeline -u jdbc:hive2://apm-cdh02:10000/test
Connecting to jdbc:hive2://apm-cdh02:10000/test
Connected to: Apache Hive (version 1.2.1000.2.6.4.0-91)
Driver: Hive JDBC (version 1.2.1000.2.6.4.0-91)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.6.4.0-91 by Apache Hive
0: jdbc:hive2://apm-cdh02:10000/test> show tables;
Error: Error while compiling statement: FAILED: HiveAccessControlException Permission denied: user [anonymous] does not have [USE] privilege on [test
0: jdbc:hive2://apm-cdh02:10000/test>
无论怎么切换用户,访问的时候都显示是匿名用户。
[root@apm-cdh03 ~]# beeline --help
Usage: java org.apache.hive.cli.beeline.BeeLine
-u <database url> the JDBC URL to connect to
-r reconnect to last saved connect url (in conjunction with !save)
-n <username> the username to connect as
- 使用jdbc方式连接hive没有提供用户名,hive认为请求者为anonymous 用户;
- 默认情况下,是不允许远程以匿名用户访问的,如果访问会提示权限不足;
提升权限
所以在访问的时候指定用户
[root@apm-cdh03 ~]# beeline -n hive -u jdbc:hive2://apm-cdh02:10000/test
Connecting to jdbc:hive2://apm-cdh02:10000/test
Connected to: Apache Hive (version 1.2.1000.2.6.4.0-91)
Driver: Hive JDBC (version 1.2.1000.2.6.4.0-91)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.6.4.0-91 by Apache Hive
0: jdbc:hive2://apm-cdh02:10000/test> show tables;
+----------------+--+
| tab_name |
+----------------+--+
| test_customer |
+----------------+--+
1 row selected (0.75 seconds)
0: jdbc:hive2://apm-cdh02:10000/test>