版本:my5.6.22-1.linux64
一.安装Mysql
1 判断centos上是否有安装,执行命令rpm -qa |grep mysql
2 如果已经安装,需要删除原有的,防止冲突,执行命令
$ rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps
3 安装mysql的服务端,执行命令
$rpm -i MySQL-server-5.6.31-2.el6.i686.rpm
4 启动mysql服务,执行命令mysqld_safe &
5 安装mysql的客户端,执行命令rpm -i MySQL-client-5.6.31-2.el6.i686.rpm
6 设置root用户的密码,执行命令mysql_secure_installation
7 修改mysql允许远程访问,在mysql命令行下执行命令
>grant all on *.* to 'root'@'master' identified by ‘123456';
>flush privileges;
二.在Hive上集成Mysql
1 将mysql的JDBC connector.jar放到hive的lib目录下
2 修改hive/conf目录下的文件hive-site.xml
修改下面红色字体位置的值
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master: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>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
注:如果Mysql root密码无法设置按照如下操作进行
# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld restart
# mysql -u root -p
Enter password: <输入新设的密码newpassword>
mysql>
如果提示没有设置Password 执行如下命令
$mysql -u root -p
>set PASSWORD=PASSWORD(‘123456’);