LOAD DATA LOCAL INFILE - File not found


#1

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


#2

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


#3

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

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

but also, File not found. :frowning:


#4

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

Your files should be located in public_html folder…


#5

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


#6

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


#7

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


#8

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.


#9

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:


#10

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?


#11

New Panel. I am new here :slight_smile:


#12

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:


#13

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


#14

I hope it worth our efforts. :slight_smile:


#15

Are you able to use this function?


#16

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


#17

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)


#18

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


#19

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.


#20

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.