Hive CLI connects to a remote HiveServer1 instance using the Thrift protocol. To connect to a server, you specify the host name and optionally the port number of the remote server:
> hive -h <hostname> -p
<port>
Beeline connects to a remote HiveServer2 instance using JDBC. Thus, the connection parameter is a JDBC URL that’s common in JDBC-based clients:
> beeline -u <url> -n <username> -p
<password>
Query Execution
Executing queries in Beeline is very similar to that in Hive CLI.
In Hive CLI:
> hive -e <query inquotes>
> hive -f <query file name>
In Beeline:
> beeline -e <query in quotes>
> beeline -f <query file name>