hive、mysql安装报错
版本信息
Mysql 8.0.23 Hadoop 3.3 hive 3.1.2
1、命令:grant all . to hive@localhost identified by ‘hive’;
**错误:**RROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘. to hive@localhost identified by ‘hive’’ at line 1
解决:
CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive';
GRANT ALL ON *.* TO 'hive'@'localhost';
FLUSH PRIVILEGES #让权限生效。
查看mysql默认密码
root@dwh-VirtualBox:/etc/mysql# cat debian.cnf
用登录的用户密码登录
sudo mysql -uroot -p
安装后自己有一个默认的用户名以及密码。
sudo vi /etc/mysql/debian.cnf
user = debian-sys-maint
password = 8X4sxdS9HSR46AVQ
修改MySql密码
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY '你的密码’;
2、启动hive报错:guava-19.0.jar版本不兼容
**错误:**Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;
**解决:**hadoop和hive的guava-19.0.jar版本不兼容,将低版本的删除换成高版本的就行。
3、启动hive报错:缺失jar包
**错误:**Exception in thread “main” java.lang.RuntimeException: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag ; expected .
**解决:**在Mysql官网下载mysql-connector-java-8.0.23.jar包,将包复制到hive下的lib中。
4、hive启动报错:配置文件格式错误
**错误:**com.ctc.wstx.exc.WstxParsingException: Unexpected close tag ; expected .
at [row,col,system-id]: [7,11,“file:/opt/hive/conf/hive-site.xml”]
**解决:**配置文件中成对出现的<>可能会有问题,仔细检查就能解决。
5、hive启动报错:未初始化数据库
**错误:**Required table missing : “VERSION
” in Catalog “” Schema “”.
**解决:**执行命令
cd ~/hive/bin
./schematool -initSchema -dbType mysql
6.输出结果时 需要在hdfs中input 把文件file1 file2放到里面
./bin/hdfs dfs -mkdir input
./bin/hdfs dfs -put /opt/hadoop/input/file1.txt input
词频统计代码
hive> create table docs(line string);
hive> load data inpath ‘input’ overwrite into table docs;
hive>create table word_count as
select word, count(1) as count from
(select explode(split(line,’ '))as word from docs) w
group by word
order by word;