hive本地mysql

一、安装mysql数据库

1.安装mysql

使用命令:yum install mysql mysql-server

2.设置mysql为开机启动

使用命令:chkconfig -add mysqld  添加mysql服务

使用命令:chkconfig msyqld on

3.启动mysql

service mysqld restart

4.修改本地mysql用户密码

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'IDENTIFIED BY '123';

注意:是localhost而不是127.0.0.1就可以的,hive是本地启动模式默认会使用msyql数据库的user表中host为localhost的root用户登录mysql数据库。

5.刷新用户权限

flush privileges;

6.最好重启mysql服务

service mysqld restart

二、安装配置hive

1.解压hive的tar包

tar -xzvf apache-hive-1.2.1-bin.tar.gz

2.配置hive

在hive的conf目录下默认是没有hive-site.xml,将hive-default.xml 复制一个出来

cp hive-default.xml hive-site.xml

 配置hive-site.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
--><configuration>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive_remote/warehouse</value>
</property>

<property>
  <name>hive.metastore.local</name>
  <value>true</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost/hive_remote?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>root</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>123</value>
</property>


</configuration>

3.启动hive

在hive的目录下使用如下命令启动

./bin/hive



你可能感兴趣的:(hive本地mysql)