1.brew install hive
2. 进入mysql:
mysql -uroot -proot进入mysql
show databases;
查看databases,若进入hive数据库,则是use hive;
3. conf文件夹中新建两个文件hive-site.xml,conf文件是配置文件
hive-site.xml的内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.server2.logging.operation.log.location</name>
<value>/tmp/hive/operation_logs</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/tmp/hive</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/tmp/hive</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/tmp/hive</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
</configuration>
hive-env.sh的内容如下
HADOOP_HOME=/usr/local/Cellar/hadoop/2.8.2
export HIVE_CONF_DIR=/usr/local/Cellar/hive/conf
4.在/bin/下执行初始化
./schematool -initSchema -dbType mysql--verbose
5.执行hive进入hive中,在bin目录下
./hive执行后,
create table nextflower
> (name string,age int); #创建表
hive常见问题:http://blog.csdn.net/seashouwang/article/details/77867134