How to use password-file in Apache Sqoop?

 There are 3 ways to pass password in sqoop import command:

1. --password mypassword --> not secured way 2. –P: Read the password from the console. 3. Reading password from a file. Reading the password from a file: Syntax: --password-file password-filename Example: Sqoop import --connect jdbc:mysql://localhost/sales --username root --password-file my_sqoop_password --table student We can store and use the password-file from both locations (LFS or HDFS). 1. Store and use password file from the local file system: Create a file in the local file system : ~]$ echo -n “mypassword” greater-than symbol /home/YT/pass.txt Here we saved mypassword text into pass.txt file on LFS. ~]$ cat /home/YT/pass.txt mypassword In the below example, we can see the --password-file command with the local file system. Example: Sqoop import --connect jdbc:mysql://localhost/sales --username root --password-file /home/YT/pass.txt --table student

2. Store and use password file from Hadoop distributed file system(HDFS): Copy pass.txt file from local file system to HDFS : ~]$ hadoop fs -put /home/YT/pass.txt /user/YT Here we copied the pass.txt file on HDFS. ~]$ hadoop fs -cat /user/YT/pass.txt mypassword Now, let's use the HDFS password file path with –password-file command. Example: Sqoop import --connect jdbc:mysql://localhost/sales --username root --password-file /user/YT/pass.txt --table student

Comments

Popular posts from this blog

SQOOP file format

Why do we use $CONDITIONS in Apache Sqoop?

Sqoop where condition , Sqoop join two tables