There is no option to set a default directory for LOAD DATA LOCAL INFILE
.
After sending LOAD DATA LOCAL INFILE statement to the server, the server parses the statement extracts the filename and requests content of specified filename from the client.
If the client is not able to open the file, an error will be returned.
So if you don't specify a path together with file name, make sure that the file is in your current working directory (which might differ from the directory where your application was started).
Best practice is always to specify the full path.
MySQL 8 for example offers to set the option MYSQL_OPT_LOAD_DATA_LOCAL_DIR,
which affects the client-side LOCAL capability for LOAD DATA operations. It specifies the directory in which files named in LOAD DATA LOCAL statements must be located.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…