Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
649 views
in Technique[技术] by (71.8m points)

hadoop - Connecting to Hive using Beeline

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...