下載安裝MariaDBhtml
下載地址爲https://mariadb.com/downloads/,下載完壓縮包後進行解壓,以下列表java
使用 rpm -ivh MariaDB-gssapi-server-10.4.7-1.el7.centos.x86_64.rpm --nodeps --force進行安裝服務端
使用rpm -ivh MariaDB-client-10.4.7-1.el7.centos.x86_64.rpm --nodeps --force進行安裝客戶端 node
啓動mariadb,啓動命令 service mysql start mysql
啓動客戶端,默認沒有用戶名和密碼,使用mysqladmin -u root -p password ex 設置用戶名密碼,輸入命令後進行回車,再輸入密碼便可 sql
登錄mysql,將mysql.user表下的host改成通配ip數據庫
update mysql.user set host='%' where host='localhost'; flush privileges;
使用maven下載mysql鏈接器centos
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.46</version> </dependency>
將mysql-connector-java-5.1.46.jar放入hive安裝路徑的lib目錄下api
更改hive-site.xml相關配置socket
<property> <name>javax.jdo.option.ConnectionURL</name> <!--jdbc:derby:;databaseName=metastore_db;create=true--> <value>jdbc:mysql://master:3306/metastore?createDatabaseIfNotExist=true</value> <description> JDBC connect string for a JDBC metastore. To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL. For example, jdbc:postgresql://myhost/db?ssl=true for postgres database. </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>
初始化hive元數據庫使用./schematool -dbType mysql -initSchema 指定mariadb做爲hive的元數據存儲庫maven
登錄mariadb進行驗證,輸入show databases;命令發現已經存在元數據庫「metastore」,而且該庫下已經存在元數據表了。
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | metastore | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.001 sec)
錯誤處理
錯誤緣由
解決方案
該錯誤引發緣由可能有兩方面,鏈接方式和用戶權限問題,解決步驟以下 (1): 將auth_socket鏈接方式改成mysql_native_password。重啓mysql服務, 命令以下
update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root'; flush privileges; service mysql restart
(2):mysql root用戶權限問題,修改root權限便可
mysql> grant all privileges on *.* to root@'localhost' identified by '密碼'; mysql> flush privileges;