Support Questions

Find answers, ask questions, and share your expertise

How to configure hive so beeline does not ask for password?

avatar
Explorer

Hi,

Now when I try to connect to hive, it asks me for username and password:

$ beeline 
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/hdp/3.0.1.0-187/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/hdp/3.0.1.0-187/hadoop/lib/slf4j-log4j12-1.7.25.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]
Connecting to jdbc:hive2://follower-2.europe-west3-b.c.XXXXXX.internal:2181,follower-1.europe-west3-b.c.XXXXXX.internal:2181,follower-3.europe-west3-b.c.XXXXXX.internal:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
Enter username for jdbc:hive2://follower-2.europe-west3-b.c.XXXXXX.internal:2181,follower-1.europe-west3-b.c.XXXXXX.internal:2181,follower-3.europe-west3-b.c.XXXXXX.internal:2181/default: username
Enter password for jdbc:hive2://follower-2.europe-west3-b.c.XXXXXX.internal:2181,follower-1.europe-west3-b.c.XXXXXX.internal:2181,follower-3.europe-west3-b.c.XXXXXX.internal:2181/default: ****************
18/11/21 16:30:23 [main]: INFO jdbc.HiveConnection: Connected to leader-1.europe-west3-b.c.XXXXXX.internal:10000
Connected to: Apache Hive (version 3.1.0.3.0.1.0-187)
Driver: Hive JDBC (version 3.1.0.3.0.1.0-187)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.0.3.0.1.0-187 by Apache Hive
0: jdbc:hive2://follower-2.europe-west3-b.c.i>

How can I configure it so it does not ask for username/password?

I have several users connecting to it. Can I have different username/password for each user if disabling it is not possible?

Best Regards,

Arindam

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@Arindam Choudhury ,

You can use the below link which talks about creating a file called beeline-hs2-connection.xml and providing the credentials information there.

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-Usinghive-si...

View solution in original post

5 REPLIES 5

avatar
Super Collaborator

@Arindam Choudhury I think the only way to do it is to set the Hiveserver2 to 'No authentication' mode.

If you really want anyone to connect anonymously that is what you could do.

avatar
Expert Contributor

@Arindam Choudhury ,

You can use the below link which talks about creating a file called beeline-hs2-connection.xml and providing the credentials information there.

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-Usinghive-si...

avatar
Explorer

Hi @Mahesh Balakrishnan,

How can I add beeline-hs2-connection.xml? I can not find it in ambari server page.

Thanks,

avatar
Explorer

I created /etc/hive/conf/beeline-hs2-connection.xml and it worked.

Thanks

avatar
Master Collaborator

@Arindam Choudhury

You can use the -n & -p options to specify the username and password. For instance:

beeline -u jdbc:hive2://follower-2.europe-west3-b.c.XXXXXX.internal:10000/default -n username -p password

Also instead of passing password it in plaintext as option '-p', we read a password from a permission-protected password file instead, For instance:

beeline -u jdbc:hive2://follower-2.europe-west3-b.c.XXXXXX.internal:10000/default -n username -w password_file

In short answer for your questions, when the beeline-hs2-connection.xml is present and when no other arguments are provided, Beeline automatically connects to the URL generated using configuration files. When connection arguments (-u, -n or -p) are provided, Beeline uses them and does not use beeline-hs2-connection.xml to automatically connect.

For more details you can refer below links.

https://issues.apache.org/jira/browse/HIVE-14063

https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients


Please accept the answer you found most useful