Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqoop Import --password-file function not working properly in sqoop 1.4.4

I am using hadoop-1.2.1 and sqoop version is 1.4.4.

I am trying to run the following query.

sqoop import --connect jdbc:mysql://IP:3306/database_name --table clients --target-dir /data/clients --username root --password-file /sqoop.password -m 1

sqoop.password is a file which is kept on HDFS in path /sqoop.password with permission 400.

It is giving me an error

Access denied for user 'root'@'IP' (using password: YES)

Can anyone provide solution for this? Thanks in advance.

like image 523
Kanav Narula Avatar asked Apr 17 '15 10:04

Kanav Narula


4 Answers

"\n" is being written in file when you vi the file and write the password. Better use the below approach to avoid problems

echo -n "Your_sqoop_password" > sqoop.password

like image 110
Nandakishore Avatar answered Sep 18 '22 15:09

Nandakishore


Not sure if you are still having this issue. The password file can be in any folder. Try the following syntax and it should work:

--password-file file:///user/root/database.password
like image 24
ganeshrj Avatar answered Sep 22 '22 15:09

ganeshrj


As per the sqoop documentation

You should save the password in a file on the users home directory with 400 permissions and specify the path to that file using the --password-file argument, and is the preferred method of entering credentials. Sqoop will then read the password from the file and pass it to the MapReduce cluster using secure means with out exposing the password in the job configuration. The file containing the password can either be on the Local FS or HDFS.

If I am running my sqoop job with root user then my password file will be in /user/root/ in HDFS

sqoop import --connect jdbc:mysql://database.example.com/employees \
    --username venkatesh --password-file /user/root/database.password

For more details you can check this

like image 20
Prasad Khode Avatar answered Sep 18 '22 15:09

Prasad Khode


While creating password, use echo -n option. (-n option removes all trailing spaces).
Suppose you have a password "myPassword" and you want to save it to a file sqoop.password, then follow below steps:

  1. Create password using command

    echo -n "myPassword" > sqoop.password
    
  2. Upload the file to HDFS as the file needs to be present in HDFS

    hadoop fs -put sqoop.password /user/keepMyFilesHere
    
  3. Write the scoop import command

    sqoop list-tables --connect jdbc:mysql://localhost/kpdatabase --username root --password-file /user/karanpreet.singh/sqoop.password
    

This will definitely work!

like image 35
KP Fingh Avatar answered Sep 20 '22 15:09

KP Fingh