LOAD DATA LOCAL INFILE - File not found

Hi,

I’m trying to load a csv file into MySQL, using LOAD DATA LOCAL INFILE, which is 1000x faster than processing it with php.

It works on local, but in 000webhost,mysql cannot find the file. I have tested puting file in /tmp directory, but it does not work either:

LOAD DATA LOCAL INFILE ‘/tmp/data.csv’ INTO TABLE data;

–>

SQLSTATE[HY000]: General error: 2 File ‘/tmp/data.csv’ not found (Errcode: 2)

How can I achieve this?

Thanks

1 Like

Try using the full server path (ie: /root/h1/1234....)

1 Like

Hmm I have used variable DIR , and it gives the path:

/storage/h9/###/######/tmp/data.csv’

but also, File not found. :frowning:

[ ... ]/tmp/data.csv ?

Your files should be located in public_html folder…

Tried also ‘/storage/h9/###/######/public_html/data.csv’
:confused:

Try replacing the slash with backslash: \storage\h9\###\######\public_html\data.csv

\storage\h9#########\public_html\data.csv not found either :frowning:

Try both, please:

LOAD DATA LOCAL INFILE '/storage/h9/###/######/public_html/data.csv' INTO TABLE data;
LOAD DATA INFILE '/storage/h9/###/######/public_html/data.csv' INTO TABLE data;

Make sure file.csv is in public_html/

If it doesn’t work, I honestly don’t know. :neutral_face:

Delete the database, create a new one, and try again. I only suppose that this problem has been generated by the phpMyAdmin() error, however it’s an odd assumption.

I have tested both of them.
The first one, which I think should work, responds with a 'File Not Found’
The second, without ‘LOCAL’, says:

SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user ‘xxxxxxxxx’@’%’ (using password: YES)
:frowning:

SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user ‘xxxxxxxxx’@’%’ (using password: YES)

This error pops up probably because we don’t have root access to the database.

Just out of curiosity, are you hosted on the old or on the new cPanel?

New Panel. I am new here :slight_smile:

1 Like

I don’t know. I really don’t.

Erase the database, create a new one, and try again.

I hope a moderator/administrator will come here and ditch things out. Maybe loading files into database is an unsupported feature, who knows… :confused:

1 Like

Let’s see, it is the only ‘but’ I have :slight_smile:
Thank you for your time anyway!

1 Like

I hope it worth our efforts. :slight_smile:

Are you able to use this function?

Yes, but i would like to do it programatically , so it can be automated.

Hello, same problem here. Still looking for an answer.

Error: LOAD DATA LOCAL INFILE ‘channels.txt’ INTO TABLE canale
File ‘channels.txt’ not found (Errcode: 2)

or

Error: LOAD DATA INFILE ‘channels.txt’ INTO TABLE canale
Access denied for user ‘idxxxxxxx_myusername’@’%’ (using password: YES)

@andrius @Giedrius, could you please shed some lights here…

Are you guys using the correct directory if that makes sense?

Each account has different numbers as above you see 10001 your account will be different.

Create PHP info file to reveal your directory.

[code]<?php

// Show 000webhost PHP information specific to your account
phpinfo();

?>

[/code]

Paste this into a file called info.php or showinfo.php and upload to public_html and then visit it.

The access denied error could mean that:
‘user’@‘localhost’ does not have the FILE privilege (GRANT FILE on database.* to user@‘localhost’ IDENTIFIED BY ‘password’);
I think it’s not about the correct directory.