Connecting to Hive using Beeline

拈花ヽ惹草 提交于 2019-11-29 03:01:58

问题


I am trying to connect to hive installed in my machine through Beeline client. when I give the 'beeline' command & connect to Hive, the client is asking for user name & password

!connect jdbc:hive2://localhost:10000/default

I have no idea what is the user name and password I am supposed to give. Do I have to add the credential(user name & password) in some configuration file?


回答1:


no username and no password.

!connect jdbc:hive2://localhost:10000/default

  Enter username for jdbc:hive2://localhost:10000/default: <press Enter>
  Enter password for jdbc:hive2://localhost:10000/default: <press Enter>

Just press enter. It works for me.

Or try this.

!connect jdbc:hive2://localhost:10000/default "" "" ""



回答2:


Accessing HIVE via Beeline:

Starting beeline client

beeline --incremental=true

Note: The command line option “—incremental=true” is optional, but will extend the amount of time that you can remain idle and not have your connection dropped.

Connecting to hive2 server

!connect jdbc:hive2://silver-server-
hive.app.google.com:10000/default

Note: You will be prompted for your username & password. USE user name and Password

beeline> !connect jdbc:hive2:// silver-server-hive.app.google.com:10000/default
scan complete in 3ms
Connecting to jdbc:hive2:// silver-server-hive.app.google.com:10000/default
Enter username for jdbc:hive2:// silver-server-hive.app.google.com:10000/default:suman
Enter password for jdbc:hive2:// silver-server-hive.app.google.com:10000/default: *********

Setting Your Queue (if any)

set mapred.job.queue.name=<your queue name>; 

Note: You need to set a queue in order to run queries.

Setting Your Database

USE google_map_data;

Note: You should be in a database when executing queries.

Reconnecting an inactive session

!reconnect jdbc:hive2:// silver-server-hive.app.google.com:10000/default; 

Quitting beeline client

!quit

Notes:

  • Loading beeline, the URL and providing your username & password in one command:

beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000\ 
-n <yourname> -p <yourpassword> --incremental=true**

Basic Beeline Queries

Beeline supports a rich set of SQL query functions.

Getting Information About Data

SHOW DATABASES;
USE <database>;

SHOW TABLES;
DESC <table>;
DESC FORMATTED <table>;

Simple limited select statements

SELECT * FROM google_map_city limit 25;



回答3:


Using beeline to hive server where Kerberos Security is enabled

 beeline -u "jdbc:hive2://<Server Ip>:<port>/sample;principal=<hive user>/<Server Ip>@<relam>;retries=3"

Example

 beeline -u "jdbc:hive2://10.10.10.10:8071/sample;principal=hive/10.10.10.10@abc.com;retries=3"



回答4:


You can use blank username and password as @sravan mentioned. This will execute the query as the user that the hiveserver2 process is running as.

However, if you have set the hive.server2.enable.doAs property in your hive-site.xml or put it in hiveconf while running hiveserver2 then you can optionally pass a username and password via the prompt. In this case hive will execute the query as the passed username using the given password. The username here is a system username.

In some scenarios it's required - say you are running the hiveserver2 process as the user 'hive' but you have an external table defined with HDFS path /user/alex/table1, which is owned by the user 'alex' and no other user has read/write access on this location. In this case running the query as 'hive' - by putting empty username and password - will not work since it will not be able to access the directory and throw a permission denied Exception.




回答5:


It is the user id and password that is used to login to the cluster. Some times it is the edge nodes credentials that you use to login to the server. The best way to avoid this is by using the below command

beeline -u jdbc:hive2://localhost:10000/default

If you are already logged in to some node through putty you won't be prompted with any user id or password.

EDIT

Trick: To avoid typing the whole beeline string repetitively it is good to create an alias in your bash_profile file.

just add the below line in bash profile (with kerberos security suggested by @Harsimranjit Singh Kler) beeline -u jdbc:hive2://<hostname>:10000/default;principal=hive/<hostname>@<realm>;ssl=true; and source the bash_profile (source .bash_profile) and you are done. The next time on just type beeline and it will connect to the hive2 server




回答6:


Yes, you can set the username and password in the hive-site.xml file inside tge conf folder. Default credentials are APP/mine.

how to get database username and password in hive




回答7:


• Loading beeline, the URL and providing your username & password in one command:

**beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000\ 
-n <yourname> -p <yourpassword> --incremental=true**


来源:https://stackoverflow.com/questions/29113323/connecting-to-hive-using-beeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!