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.
"\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
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
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
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:
Create password using command
echo -n "myPassword" > sqoop.password
Upload the file to HDFS as the file needs to be present in HDFS
hadoop fs -put sqoop.password /user/keepMyFilesHere
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With