Reputation: 1707
I am learning hadoop sqoop. I am working on a hortonworks sandbox (a hadoop virtual machine of single node: http://hortonworks.com/products/hortonworks-sandbox/#install).
I am trying to load a csv file via sqoop into a mysql table. I have created a database flightinfo and a table weather in it. I created a table in hive called sqoop_tmp with the file location of that csv file.
I used following command to load the csv into mysql:
sqoop export --connect jdbc:mysql://localhost/flightinfo –-table weather –-export-dir /apps/hive/warehouse/sqoop_tmp
update: @z-1 I tried your code and it returns something different
Upvotes: 2
Views: 4097
Reputation: 1185
You have to provide username and password of MySQL and must have permissions to access the database.
It looks like you did a fresh install of mysql and didn't not configure the root account to secure with root password.
You can do that using the following steps:
$ mysqladmin -u root password "newpassword"
for example $ mysqladmin -u root password mysql-root-password
$ sudo service mysqld restart
or $ sudo /etcinit.d/mysqld restart
$ mysql -u root -P
and enter the password when prompted.If you have your database created as root user. Now you can issue the following sqoop command to export data from hdfs to sqoop database.
$ sqoop export --connect jdbc:mysql://localhost/flightinfo --username root -P --table weather --export-dir /apps/hive/warehouse/sqoop_tmp
Still facing permission issue?? Permission to the user to access database is the problem.
Then, You should be able to solve by granting permissions using the steps below.
Login to MySQL using $ mysql -u root -P
mysql> GRANT all PRIVILEGES on filghtinfo.* to 'root'@'localhost' IDENTIFIED BY 'password'
Note: The password you set here should be used from sqoop.
Upvotes: 1
Reputation: 5881
try with username and password of mysql
sqoop export --connect jdbc:mysql://localhost/flightinfo --table weather --export-dir /apps/hive/warehouse/sqoop_tmp --username SomeUser -P
Note - user should have permission.
Upvotes: 1
Reputation: 1832
Try this:
sqoop export --connect jdbc:mysql://localhost/flightinfo --table weather --export-dir /apps/hive/warehouse/sqoop_tmp
You had –-
not --
. These two are not the same.
Upvotes: 0