4

I want to store the password into a file & later use the same in sqoop command.

According to sqoop documentation --password-file option allow us for storing password. so i am storing it in pwd file with password abc text only. & hits the below command.

sqoop import --connect jdbc:mysql://localhost:3306/db --username bhavesh --password-file /pwd --table t1 --target-dir '/erp/test' 

assuming pwd file is stored over HDFS

as a result i am getting following error :

java.sql.SQLException: Access denied for user 'bhavesh'@'localhost' (using password: YES)

When I perform the same operation using -p option it works fine for me.

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
Bhavesh Gadoya
  • 196
  • 2
  • 13

2 Answers2

1

For a saved sqoop job, I was getting the same error. I stored the password in the metastore and that worked for me.

Making changes to the following configuration property in the file sqoop-site.xml which is usually stored here - /etc/sqoop/conf/sqoop-site.xml

<property>
    <name>sqoop.metastore.client.record.password</name>
    <value>true</value>
    <description>If true, allow saved passwords in the metastore.
    </description>
</property>

After making these changes, create the sqoop job and running the following command you would be able to see the password stored.

sqoop job --show [job_name]

asarapure
  • 605
  • 1
  • 6
  • 18
0

You can store credential on HDFS.

Create credential using this command:

hadoop credential create mysql.password -provider jceks://hdfs/user/<your_hadoop_username>/mysqlpwd.jceks

When executed on the client machine it will ask to provide a password, then please enter the MySQL password that you were provided with -P option for sqoop command.

sqoop import --connect jdbc:mysql://localhost:3306/db --username bhavesh --password-alias mysql.password --table t1 --target-dir /erp/test

And run this modified command in that I have replaced

--password-file

with

--password-alias

File in hdfs contain a password in an encrypted format that cannot be recovered.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Vikramraj
  • 188
  • 4
  • 18