(二)在mysql中准备数据
1、创建数据库交授权
create database sqoop;
use sqoop;
GRANT ALL PRIVILEGES ON sqoop.* TO ‘‘@‘localhost‘;
2、创建表
create table widgets(
id int not null primary key auto_increment,
widget_name varchar(64) not null,
price decimal(10,2),
design_date date,
version int,
design_comment varchar(100));
3、插入数据
insert into widgets values(null, ‘sprocket‘, 0.25, ‘2010-02-10‘, 1, ‘Connects two gizmos‘);
insert into widgets values(null, ‘gizmos‘, 4.00, ‘2009-11-30‘, 4, null);
insert into widgets values(null, ‘gadget‘, 99.99, ‘193-08-13‘, 13, ‘Our flagship product‘);
3、查看数据
$ hadoop fs -cat widgets/part-m-00000
15/05/15 10:29:29 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
1,sprocket,0.25,2010-02-10,1,Connects two gizmos
2,gizmos,4.00,2009-11-30,4,null
3,gadget,99.99,0193-08-13,13,Our flagship product
异常:
1、若没执行GRANT ALL PRIVILEGES ON sqoop.* TO ‘‘@‘localhost’;
则会出现以下异常:
15/05/15 10:25:28 ERROR manager.SqlManager: Error executing statement: java.sql.SQLException: Access denied for user ‘‘@‘localhost‘ (using password: NO)
java.sql.SQLException: Access denied for user ‘‘@‘localhost‘ (using password: NO)