0

i would like to import csv file in mysql database.

my query would be like the following.

query = "LOAD DATA INFILE '"+filename+"' INTO TABLE testtable FIELDS TERMINATED BY ',' (text,price)";

But i got the following error while importing file.

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

for full source code you can see http://www.javalobby.org/java/forums/t53674.html.

Any Help is greatly appriciated.

Thanks.

1

3 Answers 3

2
  1. the user you are using does not have the privileges to load data
  2. you might also need to specify LOAD DATA LOCAL
  3. make use user root allowed to access other than from localhost
Sign up to request clarification or add additional context in comments.

Comments

0

as error shows, you should double check if user-password-host-db combination is correct. this is what the error tells you.

4 Comments

Thanks jancha. my username,password and databasename is absolutely correct, still i got the same error.
If i tried other sql statment then it's working properly. but when i fired the following query, i get the same error. query = "LOAD DATA INFILE '"+filename+"' INTO TABLE testtable FIELDS TERMINATED BY ',' (text,price)";
so, if you can execute other query, could be also grants issue. also, make sure that the file you are trying to load is "readable" by the user that is executing your script.
Thanks for your help. my issue is solved now. The problem is that i don't have privileges to load data.
0

Make sure you are allowed to log into the database as root and you have the correct password in your connect string (caspian)

Connection conn = db.connect("jdbc:mysql://localhost:3306/test","root","caspian");

3 Comments

If i tried other sql statment then it's working properly. but when i fired the following query, i get the same error. query = "LOAD DATA INFILE '"+filename+"' INTO TABLE testtable FIELDS TERMINATED BY ',' (text,price)";
That is strange. Could you post all your code, the whole exception stack and also indicate on which line the exception is thrown? thx
Thanks for your help. my issue is solved now. The problem is that i don't have privileges to load data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.