3

I am using LAMP in Ubuntu 12.04. I created a new user in MySQL (myserver@localhost) and granted ALL on a database to that user. There is a text file the permission of which is set to read for everyone. But when I try to load the data from that text file to the database, it says "Access denied for user 'myserver'@'localhost' (using password: YES)"

The query I used is:

LOAD DATA INFILE "~/text/member_info.txt" INTO TABLE member FIELDS TERMINATED BY '|';

I can think of a workaround with some loops in PHP but why doesn't the 'LOAD DATA INFILE' work?

Thanks.

6
  • Can you post the query you are using? Commented Jun 13, 2012 at 12:14
  • Check the password. Is it correct? Commented Jun 13, 2012 at 12:44
  • I added the query to the question @ Nico Commented Jun 13, 2012 at 13:09
  • Which password? I logged in to MySQL with the password and it was correct no problem.@Devart Commented Jun 13, 2012 at 13:09
  • 2
    Please see this post: forums.mysql.com/read.php?30,12298,12298#msg-12298. And do a bit of googling Commented Jun 13, 2012 at 13:20

1 Answer 1

1

This is due the MYSQL 5.5 version you are using in Ubuntu LTS 12.04 : mysql doc

From mysql doc comment :

You can use LOAD DATA LOCAL with recent versions of PHP without recompiling PHP.

Passing 128 (the value of the CLIENT_LOCAL_FILES constant) as the fifth parameter to mysql_connect () enables LOAD DATA LOCAL on the client side.

Example: $dbh = mysql_connect($server, $user, $pass, false, 128);

For PHP 4.3 and above.

But in fact, mysql_connect() is obsolete, and I can't find a solution using mysqli.

That's why I finally use this who solve the problem.

grant file on *.* to mydatabase@localhost identified by 'myuser';

Now $mysqli->query("LOAD DATA INFILE '".$proxy_file_name_path."' IGNORE INTO TABLE mytable (myfield)"

Sign up to request clarification or add additional context in comments.

Comments

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.