INFILE and Windows problem

Hi there,

I just discovered the INFILE option, and I think it will help our server a lot. However there is a strange path error now I have enabled the right permissions on the MySQL user:


LOAD DATA INFILE : SQLSTATE[HY000]: General error: 13 Can't get stat of '/var/lib/mysql/C:/Data/path/to/piwik/tmp/assets/Stats_option-41be599e80088d241d542bb542cccb63.csv'

According to some hacked in echos, this is what Piwik is sending to execute:


LOAD DATA INFILE 'C:/Data/path/to/piwik/tmp/assets/Stats_option-41be599e80088d241d542bb542cccb63.csv' REPLACE INTO TABLE `Stats_option` FIELDS TERMINATED BY '	' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY ' ' (option_name,option_value) LOAD DATA LOCAL INFILE 'C:/Data/path/to/piwik/tmp/assets/Stats_option-41be599e80088d241d542bb542cccb63.csv' REPLACE INTO TABLE `Stats_option` FIELDS TERMINATED BY '	' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY ' ' (option_name,option_value)

Does that mean this is a php or MySQL bug? What’s adding the additional path?

DB is on separate Ubuntu server, version “5.1.61-0ubuntu0.10.10.1-log”

Thanks in advance for any help or pointers.

Can you check the mysql config for this path (/var/lib/mysql). Maybe the datadir/basedir option is misconfigured? MySQL :: MySQL 5.7 Reference Manual :: 2.3.5.2 Creating an Option File

Thanks for your reply, the MySQL server is a different box and Ubuntu, so I think that’s a red herring.

However, I have just noticed that Piwik isn’t adding “LOCAL” to the SQL for some reason so I will debug that first.

Thanks.

Oh. Well in your case that is certainly the problem, without LOCAL the MySQL server will try to read the file from its own host.

Not sure of the implications if we just add LOCAL to that query. Let me know what you find out.

The code already tries both versions: with and without LOCAL. So it should still work…

It looks like the code should do that, but on the system check page, the second attempt is not reporting anything. It may just be a display bug, it’s difficult to tell without delving too deep.


 LOAD DATA INFILE

Using LOAD DATA INFILE will greatly speed Piwik's archiving process up. To make it available to Piwik, try updating your PHP & MySQL software and make sure your database user has the FILE privilege.
If your Piwik server tracks high traffic websites (eg. > 100,000 pages per month), we recommend to try fix this problem.

Error: 
Try #1: LOAD DATA INFILE : SQLSTATE[HY000]: General error: 13 Can't get stat of '/var/lib/mysql/C:/Data/path/to/piwik/content/tmp/assets/Stats_option-d348c55e0913f30ae92578f3c511ed6f.csv' (Errcode: 2),
Try #2: LOAD DATA LOCAL INFILE :

It looks indeed a bit confusing and I’m not sure why, sorry, if you want to debug the code you can look in core/Piwik.php function createTableFromCSVFile

see this FAQ for more info Troubleshooting - Analytics Platform - Matomo load data in file piwik