Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Beeline sample with -u -f -n -p

avatar
Rising Star

Client tries to execute hive sql inside a file via Beeline.

Anyone has working sample of how to use "beeline -u <url> -n <user> -f <file> -p <password>"? I have tried this, but does not work.

1 ACCEPTED SOLUTION

avatar
Master Mentor
@rxu@hortonworks.com

You can use this

and if you want to prompt for password only then here you go

[root@nsfed01 ~]# cat r1.sh

#read -p "enter HS2 hostname: " HS2

#read -p "enter username: " username

echo "enter password"

read -s passwd

#read -p "enter filename: " filename

beeline -u jdbc:hive2://n3:10000/default -n neeraj -p $passwd -f f.sql

[root@nsfed01 ~]#

447-screen-shot-2015-11-11-at-115427-am.png

View solution in original post

5 REPLIES 5

avatar
Expert Contributor
/usr/hdp/current/hive-client/bin/beeline -n hrt_qa -p pwd -u "jdbc:hive2://host:2181,host2:2181,host3:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" --outputformat=tsv -f /grid/0/hadoopqe/artifacts/tmp-820871

avatar
Rising Star

Forgot to mention, user does not want to show his password in plaintext, he wants to type in prompt...

avatar
Master Mentor

@rxu@hortonworks.com

This worked for me

[root@nsfed01 ~]# beeline -u jdbc:hive2://n2:10000/default -n hive -p hive -f f.sql

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

Connecting to jdbc:hive2://n2:10000/default

Connected to: Apache Hive (version 1.2.1.2.3.2.0-2950)

Driver: Hive JDBC (version 1.2.1.2.3.2.0-2950)

Transaction isolation: TRANSACTION_REPEATABLE_READ

0: jdbc:hive2://n2:10000/default> select * from test;

+----------+-----------+--+

| test.id | test.val |

+----------+-----------+--+

+----------+-----------+--+

No rows selected (0.767 seconds)

0: jdbc:hive2://n2:10000/default>

Closing: 0: jdbc:hive2://n2:10000/default

[root@nsfed01 ~]#

avatar
Rising Star

Forgot to mention, user does not want to show his password in plaintext, he wants to type in prompt...

avatar
Master Mentor
@rxu@hortonworks.com

You can use this

and if you want to prompt for password only then here you go

[root@nsfed01 ~]# cat r1.sh

#read -p "enter HS2 hostname: " HS2

#read -p "enter username: " username

echo "enter password"

read -s passwd

#read -p "enter filename: " filename

beeline -u jdbc:hive2://n3:10000/default -n neeraj -p $passwd -f f.sql

[root@nsfed01 ~]#

447-screen-shot-2015-11-11-at-115427-am.png