安装Hive前,首先装好MySQL,MySQL数据库可以支持多个用户同时使用Hive连接MySQL数据库,共享使用metastore中的内容访问Hive,并且MySQL本身具有成熟的分布式特性,可以采用多台MySQL机器提供metastore内容服务。

MySQL安装包:
MySQL-server-5.5.52-1.linux2.6.x86_64.rpm 服务器端
MySQL-client-5.5.52-1.linux2.6.x86_64.rpm 客户端

将这两个安装包上传到,笔者上传的是/home/gznc用户下

hive mysql安装配置 安装hive前要安装mysql_hive

在安装之前,进入root用户,查找系统自带的mysql,然后删除,命令:

rpm -qa|grep -i mysql

hive mysql安装配置 安装hive前要安装mysql_hive mysql安装配置_02

找出系统自带的mysql以后,删除。命令:

rpm -e --nodeps 包名(注:你查找出来的系统自带的mysql包)如下图所示,查找出来多少个就删除多少个

hive mysql安装配置 安装hive前要安装mysql_mysql_03

删除系统自带的mysql的开发头文件和库,命令:

[root@master gznc]# rm -rf /usr/lib/mysql
[root@master gznc]# rm -rf /usr/lib64/mysql
[root@master gznc]# rm -rf /usr/include/mysql
[root@master gznc]# rm -rf /etc/my.cnf
[root@master gznc]# rm -rf /var/lib/mysql

接下来就是安装MySQL服务端

[root@master gznc]# rpm -ivh MySQL-server-5.5.52-1.linux2.6.x86_64.rpm

出现这个界面表示MySQL服务器端安装成功

[root@master gznc]# rpm -ivh MySQL-server-5.5.52-1.linux2.6.x86_64.rpm 
warning: MySQL-server-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
161111 10:32:12 [Note] /usr/sbin/mysqld (mysqld 5.5.52) starting as process 2403 ...
161111 10:32:12 [Note] /usr/sbin/mysqld (mysqld 5.5.52) starting as process 2411 ...

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h master password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf,改名为my.cnf作为mysql配置文件。命令:

[root@master gznc]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

hive mysql安装配置 安装hive前要安装mysql_hive_04

下面看看如何启动和停止mysql服务,命令如下:

[root@master gznc]# ps -ef | grep mysql
root       2431   2343  0 10:33 pts/0    00:00:00 grep mysql
[root@master gznc]# service mysql start
Starting MySQL..                                           [  OK  ]
[root@master gznc]# service mysql stop
Shutting down MySQL.                                       [  OK  ]

hive mysql安装配置 安装hive前要安装mysql_MySQL_05

这样MySQL服务端就安装成功了,接下来安装MySQL客户端,命令:

[root@master gznc]# rpm -ivh MySQL-client-5.5.52-1.linux2.6.x86_64.rpm

出现如下界面表明MySQL客户端安装成功

[root@master gznc]# rpm -ivh MySQL-client-5.5.52-1.linux2.6.x86_64.rpm 
warning: MySQL-client-5.5.52-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

MySQL安装完后,目录结构如下表,输入如下命令:ls /usr/bin/mysql*

[root@master gznc]# ls /usr/bin/mysql*
/usr/bin/mysql                       /usr/bin/mysqlhotcopy
/usr/bin/mysqlaccess                 /usr/bin/mysqlimport
/usr/bin/mysqlaccess.conf            /usr/bin/mysql_install_db
/usr/bin/mysqladmin                  /usr/bin/mysql_plugin
/usr/bin/mysqlbinlog                 /usr/bin/mysql_secure_installation
/usr/bin/mysqlbug                    /usr/bin/mysql_setpermission
/usr/bin/mysqlcheck                  /usr/bin/mysqlshow
/usr/bin/mysql_convert_table_format  /usr/bin/mysqlslap
/usr/bin/mysqld_multi                /usr/bin/mysqltest
/usr/bin/mysqld_safe                 /usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysqldump                   /usr/bin/mysql_upgrade
/usr/bin/mysqldumpslow               /usr/bin/mysql_waitpid
/usr/bin/mysql_find_rows             /usr/bin/mysql_zap
/usr/bin/mysql_fix_extensions

服务器程序为:/usr/sbin/mysqld
数据目录为:/usr/lib64/mysql/ ,默认情况下,日志文件都存在放在/var/lib/mysql下,如果要改变其存放位置,可以通过更改/etc/my.cnf

为了防止MySQL中文乱码,进入配置里面添加如下配置,命令:

[root@master gznc]# vim /etc/my.cnf

hive mysql安装配置 安装hive前要安装mysql_hive mysql安装配置_06

hive mysql安装配置 安装hive前要安装mysql_MySQL_07


hive mysql安装配置 安装hive前要安装mysql_mysql_08

启动MySQL服务,命令:

[root@master gznc]#service mysql start

默认安装完成后mysql的用户名为root,密码为空,给MySQL设置一个密码,如123456,命令:

[root@master gznc]# mysqladmin -u root password 123456

登录MySQL,命令:

[root@master gznc]# mysql -u root -p123456

hive mysql安装配置 安装hive前要安装mysql_mysql_09


hive mysql安装配置 安装hive前要安装mysql_hive mysql安装配置_10

验证MySQL对中文乱码

hive mysql安装配置 安装hive前要安装mysql_mysql_11


hive mysql安装配置 安装hive前要安装mysql_mysql_12


hive mysql安装配置 安装hive前要安装mysql_MySQL_13

至此,表示数据库安装成功并且对中文正常显示