Database Reference
In-Depth Information
A Sample Import
After you install Sqoop, you can use it to import data to Hadoop. For the examples in this
chapter, we'll use MySQL, which is easy to use and available for a large number of plat-
forms.
To install and configure MySQL, follow the online documentation . Chapter 2 (“Installing
and Upgrading MySQL”) in particular should help. Users of Debian-based Linux systems
(e.g., Ubuntu) can type sudo apt-get install mysql-client mysql-serv-
er . Red Hat users can type sudo yum install mysql mysql-server .
Now that MySQL is installed, let's log in and create a database ( Example 15-1 ).
Example 15-1. Creating a new MySQL database schema
% mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 235
Server version: 5.6.21 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql> CREATE DATABASE hadoopguide;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON hadoopguide.* TO ''@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
The password prompt shown in this example asks for your root user password. This is
likely the same as the password for the root shell login. If you are running Ubuntu or anoth-
er variant of Linux where root cannot log in directly, enter the password you picked at
MySQL installation time. (If you didn't set a password, then just press Return.)
In this session, we created a new database schema called hadoopguide , which we'll use
throughout this chapter. We then allowed any local user to view and modify the contents of
the hadoopguide schema, and closed our session. [ 94 ]
Now let's log back into the database (do this as yourself this time, not as root) and create a
table to import into HDFS ( Example 15-2 ) .
Search WWH ::




Custom Search