how to get database username and password in hive
To get hive username and password, go to hive-site.xml
and search for javax.jdo.option.ConnectionUserName
and javax.jdo.option.ConnectionPassword
. The values of these properties are your hive username and password respectively.
(Default values are APP
and mine
for username and password which can be found in hive-default.xml
)
In case, if you don't have such property in hive-site.xml. Then add these lines in hive-site.xml
:
<property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value></property><property> <name>javax.jdo.option.ConnectionPassword</name> <value>hivepass</value></property><property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value></property><property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hadoop</value></property>
Note: I have a database named hadoop in mysql for hive. Thats why the value for javax.jdo.option.ConnectionURL
is jdbc:mysql://localhost:3306/hadoop
.
After setting or finding your username and password, use it as follows:
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hiveuser", "hivepass");
Use your hive database name
instead of default
. Hope it helps!!!!
hive default user name is hive
use the below connection string for hiveserver2
"jdbc:hive2://localhost:10000/default", "hive", ""
for hiveserver1 default is empty,hiveserver2 also works with empty username and password.
jdbc:hive://localhost:10000/default
Driver name: org.apache.hadoop.hive.jdbc.HiveDriver
Username and password are empty
read the link Connecting to Hive using Beeline