yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
# 输入数据库超级管理员root的密码(注意不是系统root的密码),第一次进入还没有设置密码则直接回车
Enter current password for root (enter for none):
# 设置密码,y
Set root password? [Y/n] y
# 新密码
New password:
# 再次输入密码
Re-enter new password:
# 移除匿名用户, y
Remove anonymous users? [Y/n] y
# 拒绝root远程登录,n,不管y/n,都会拒绝root远程登录
Disallow root login remotely? [Y/n] n
# 删除test数据库,y:删除。n:不删除,数据库中会有一个test数据库,一般不需要
Remove test database and access to it? [Y/n] y
# 重新加载权限表,y。或者重启服务也许
Reload privilege tables now? [Y/n] y
测试是否能够登录成功,出现 MariaDB [(none)]> 就表示已经能够正常登录使用MariaDB数据库了
[root@mini ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
vim /etc/my.cnf
在 [mysqld] 标签下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
vim /etc/my.cnf.d/client.cnf
在 [client] 标签下添加
default-character-set=utf8
vim /etc/my.cnf.d/mysql-clients.cnf
在 [mysql] 标签下添加
default-character-set=utf8
systemctl restart mariadb
MariaDB [mysql]> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
MariaDB [mysql]>
mariadb默认是拒绝 root 远程登录的。这里用的是 navicat 软件连接数据库
systemctl stop firewalld
firewall-cmd --query-port=3306/tcp
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --query-port=3306/tcp
先通过本地链接进入数据库
mysql -u root -p
MariaDB [(none)]> use mysql;
MariaDB [(none)]> use mysql;
MariaDB [mysql]> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
MariaDB [mysql]> update user set host='%' where host='::1';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [mysql]> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
flush privileges;
systemctl restart mariadb
注意:刷新权限表是在数据库中,重启服务是在外部命令行中
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TVkgFZWo-1653389985537)(C:\Users\24602\AppData\Roaming\Typora\typora-user-images\1653362737907.png)]
选择对应版本
地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hive/
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xgzsjedO-1653389985538)(C:\Users\24602\AppData\Roaming\Typora\typora-user-images\1653381220844.png)]
tar -zxvf apache-hive-2.3.9-bin.tar.gz
mv apache-hive-2.3.9-bin hive
mv hive /opt/
vim /etc/profile
export HIVE_HOME=/opt/hive
export PATH=$PATH:$HIVE_HOME/bin
使配置文件生效
source /etc/profile
cd /opt/hive/conf
cp hive-env.sh.template hive-env.sh
vim hive-env.sh
HADOOP_HOME=/opt/hadoop
export HIVE_CONF_DIR=/opt/hive/conf
vim 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>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password to use against metastore database</description>
</property>
</configuration>
https://downloads.mysql.com/archives/c-j/
注意,下载5.1.49版本的即可,不要下载更高版本的。具体下载地址如下:
https://cdn.mysql.com/archives/mysql-connector-java-5.1/mysql-connector-java-5.1.49.tar.gz
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eN0nzOkZ-1653389985539)(C:\Users\24602\AppData\Roaming\Typora\typora-user-images\1653382598890.png)]
tar -zxvf mysql-connector-java-5.1.49.tar.gz
cd mysql-connector-java-5.1.49
mv mysql-connector-java-5.1.49.jar mysql-connector-java.jar
mv mysql-connector-java.jar /opt/hive/lib
mysql -u root -p
create database hive;
grant all on *.* to hive@localhost identified by 'hive';
flush privileges;
重要:修改hive元数据库的编码为latin1,若不修改则会导致在hive cli中使用create database(创建数据库)、create table(创建表)、drop talbe(删除表)等命令时出现卡住或报错而无法正确执行的问题。
alter database hive character set latin1;
进入指定的目录
cd /opt/hive/bin
初始化,如果要使用默认的derby数据库则将命令中的mysql替换成derby即可
./schematool -initSchema -dbType mysql
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-m8m8c5Id-1653389985539)(C:\Users\24602\AppData\Roaming\Typora\typora-user-images\1653382941819.png)]
注意:由于hive是使用HDFS来存储数据的,而且其语句默认是自动转换成MapReduce程序来执行的,所以在启动hive之前,需要先启动Hadoop集群,否则将启动失败。
start-all.sh
需要在/tmp目录下创建一个hive目录
mkdir /tmp/hive
hive
/bin
初始化,如果要使用默认的derby数据库则将命令中的mysql替换成derby即可
```bash
./schematool -initSchema -dbType mysql
[外链图片转存中…(img-m8m8c5Id-1653389985539)]
注意:由于hive是使用HDFS来存储数据的,而且其语句默认是自动转换成MapReduce程序来执行的,所以在启动hive之前,需要先启动Hadoop集群,否则将启动失败。
start-all.sh
需要在/tmp目录下创建一个hive目录
mkdir /tmp/hive
hive
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M6NqvkDw-1653389985539)(C:\Users\24602\AppData\Roaming\Typora\typora-user-images\1653383173708.png)]