Ubuntu下配置hive

1 安装MySql

ubuntu20.04中安装mysql8.0步骤_023的小陈的博客-CSDN博客

安装完后:

首先登录mysql:

建立数据库hive

create database hive;

创建hive用户:

create user 'hive'@'%' IDENTIFIED WITH mysql_native_password BY '123456789';

授权:

GRANT ALL PRIVILEGES ON *.* TO hive@'%' WITH GRANT OPTION;
#刷新权限
flush privileges;

修改/etc/mysql/mysql.conf.d/mysqld.cnf

bind-address            = 0.0.0.0  #原127.0.0.1 修改为0.0.0.0
mysqlx-bind-address     = 127.0.0.1

重启mysql服务

sudo service mysql restart

2 安装hive

下载地址Index of /hivehttps://dlcdn.apache.org/hive/

1解压后重命名为hive

2配置配置环境变量

sudo vim ~/.bashrc

添加

export HIVE_HOME=/usr/local/hive#自己的安装路径

export PATH=$PATH:${HIVE_HOME}/bin:${HIVE_HOME}/lib:

接着

source ~/.bashrc

3 进入${HIVE_HOME}/conf中:

创建hive-site.xml并添加如下内容:




  
 
    javax.jdo.option.ConnectionURL
    jdbc:mysql://hadoop200:3306/hive?createDatabaseIfNotExist=true&useSSL=false&allowPublicKeyRetrieval=true
    JDBC connect string for a JDBC metastore
  

  
    javax.jdo.option.ConnectionDriverName
    com.mysql.cj.jdbc.Driver
    Driver class name for a JDBC metastore
  

  
    javax.jdo.option.ConnectionUserName
    hive
    username to use against metastore database
  
 
  
    javax.jdo.option.ConnectionPassword
    123456789
    password to use against metastore database
  
  
    datanucleus.autoCreateTables
    True
  

  
    hive.metastore.schema.verification
    false
  
  
  
    hive.metastore.event.db.notification.api.auth
    false
  
  
  
    hive.metastore.warehouse.dir
    /user/hive/warehouse
  

然后继续在${HIVE_HOME}/conf中创建hive-env.sh,并添加如下内容:

export HADOOP_HOME=/usr/local/hadoop  #你自己的hadoop路径
export HIVE_CONF_DIR=/usr/local/hive/conf  #你自己的hive路径

最后将下载好并解压mysql的驱动jar包移动到${HIVE_HOME}/lib下

下载地址:MySQL :: Download Connector/J

Ubuntu下配置hive_第1张图片

4在${HIVE_HOME}/bin下执行以下命令(提前运行起hdfs):

schematool -dbType mysql -initSchema
schematool -dbType mysql -info
hive

5验证是否配置好hive

启动hive:

Ubuntu下配置hive_第2张图片

 创建表看能否成功:

 create table test1(id int, name string);

显示数据库:

show databases;

你可能感兴趣的:(hive,大数据,mysql)