MySql安裝及整合Hive手冊

停不下的腳步發表於2014-12-18

版本: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 mysqlJDBC connector.jar放到hivelib目錄下


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’);

相關文章