Using MySQL to manage meta

Source: Internet
Author: User

The first part installs MySQL

The second section uses MySQL to manage meta

Install MySQL

Installation

Yum-y install MySQL Mysql-server

Yum method installation requires the use of the network, can automatically continue to transmit, for the dependent package, can be automatically downloaded;

RPM method installation for the need to rely on the package, need to manually download;

MySQL Basics

View MySQL version Rpm-qi mysql-server--View Details Mysql-v--View abbreviated version information Configuration

Configure MySQL default encoding under root user

VI/ETC/MY.CNF add under the [mysqld] configuration groupDefault-character-set=utf8You must use this before adding Default-character-set=utf8--mysql5.5 under the new Add Group [MySQL] configuration group, which is recommended after 5.5Character-set-server=utf8 Put the MySQL JDBC driver package under Hive/lib (this step is to use MySQL in hive, so just to install MySQL, you can ignore this step)CP mysql-connector-java-5.1.21.jar/opt/hive/lib Configuration hive-site.xml<property> <name> Javax.jdo.option.connectionurl</name> <value>jdbc:mysql:// localhost: 3306/ Hive?createdatabaseifnotexist=true&amp;useunicode=false&amp;characterencoding=latin1</value> < DESCRIPTION&GT;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> Root</value> <description>password to use against Metastore database</description></property>

Start MySQL

chkconfig mysqld on--Set up the MySQL service boot automatically Service mysqld Start--Start MySQL server MySQL--Start the client side of MySQL start meeting the problem#service Mysqld started MySQL Daemon failed to start. Starting mysqld: [FAILED] Workaround: 1) chkconfig--list mysqld confirm MySQL boot status, 2-5 boot status when needed; 2) go to/var/lib/ls-alh view MySQL Whether the user is MySQL chown-r mysql:mysql/var/lib/mysql/if not, assign the MySQL file to MySQL 3) less/var/log/mysqld.log view the MySQL log

1. The hint table does not exist "table ' mysql.plugin ' doesn ' t exist"

2. You may not have performed mysql_install_db-u MySQL or mysql_upgrade to create the initial MySQL database

Setup MySQL password after successful MySQL installation

first install, no password, direct MySQL entry, execute the following sql:Set password for[email protected]=password (' password '); Do not install first, have password, use the following command to change Password:/usr/bin/mysqladmin-uroot-p password root

# mysql-uroot-p

Enter your password to log in

Using MySQL to manage meta

============== log in to MySQL and create a hive database ==================

# Mysql-uroot-p Enter a password to log in mysql> CREATE database Hive; Hive here must be the same as hive in the configuration. Otherwise, an error is created. Mysql> ALTER DATABASE Hive Character Set Latin1;    --Set Latin1 code mysql> show tables; --View Table

Mysql> select * from TBLs;

============== into hive, create table My==================[[email protected] bin]$ ./hive

Hive> show tables;
Ok
Time taken:3.101 seconds

hive> CREATE table my (id int,name string) row format delimited fields terminated by ' \ t ' stored as textfile;
Ok
Time taken:0.408 seconds
Hive> show tables;
Ok
My
Time taken:0.197 seconds

============== in root user, create a text file ==================

Mkdir/opt/datavi/opt/data/test.txt inserts data in it, tab-delimited (the statements created in hive are so customized) are as follows: 1 xixi2 xiaoxi============== into Hive, Add text data to table my==================

hive> Load Data local inpath '/opt/data/test.txt ' overwrite into table my;
Copying data from File:/opt/data/test.txt
Copying File:file:/opt/data/test.txt
Loading Data to Table default.my
Deleted hdfs://localhost:9000/user/hive/warehouse/my
Ok
Time taken:0.402 seconds
Hive> SELECT * from my;

Hive> Select COUNT (*) from my;

============== into MySQL, check the table my==================# mysql-uroot-p Enter the password, you can log in mysql> Use hive;

Database changed
Mysql> show tables;
+-----------------+
| tables_in_hive |
+-----------------+
| Bucketing_cols |
| CDS |
| Columns_v2 |
| Database_params |
| DBS |
| Partition_keys |
| SDS |
| Sd_params |
| sequence_table |
| SERDES |
| Serde_params |
| Sort_cols |
| Table_params |
| TBLs |
+-----------------+
Rows in Set (0.00 sec)

Using MySQL to manage meta

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.