Using relative paths in LOAD DATA LOCAL INFILE MySql

Hello,

Following my post yesterday about uploading and loading files to be used by mysql, I realized I could just do the reverse and load them using PHP, which should have access to all my files in files.000webhost.com.

However, after designing the query, the mysql returns file not found error.

I’m using relative path to reference the files, which are outside public_html. I realize I could do with absolute paths if I place it in public_html, but I wanted to avoid it, for security reasons.

So can I use relative paths in this situation?

Outside public_html: no

ok. thanks you for your answer.

1 Like

Let know if you’ve any other issues :slight_smile:

1 Like

Ok, so I was changing the php to reference the files but it still gives me file not found, despite being inside public_html. So how does one reference the files to use in the mysql script with relative or absolute paths?

@akhilkumar332

@ckhawand check :point_up_2: :point_up_2: :point_up_2: :point_up_2:

1 Like

Ok so I managed to find the file by doing a search on relative path and then converting to absolute on the sql query. If there is another better way, let me know please.

Now sql returns Access denied for user ‘*************’@’%’ (using password: YES)
The full sql query i’m running is:
LOAD DATA INFILE 'https://***********.000webhostapp.com/info/test.csv' REPLACE INTO TABLE ***** FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'

@akhilkumar332

Are you sure the database credentials are right?

1 Like

@ckhawand they are. If I switch the query to a simple select I have no problems.