Does the function 'load_file()' in MySQL must use path from the server? - mysql

This is the current only path I can use load_file() function in MySQL:
C:\ProgramData\MySQL\MySQL Server 8.0\Uploads
Can I not attach any other file from any other path?
Because I am able to attach BLOB file attachment only from the path mentioned above. But attaching a path from a \Desktop or else where.. shows values as null.
Can this be altered? If so, how?

https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_load-file
Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

Related

SSIS File System Task - Move Directory

I am extremely confused.
I have a destination directory: \\Client\D$\Data Feed\Archive. I set this as my Destination Connection in File System Task Editor.
I have a source directory: \\Client\D$\Data Feed\Plan 24-01-2020. I set this as my Source Connection in File System Task Editor. It also contains one CSV file.
For the Operation in File System Task Editor I choose Move Directory as the Operation.
All setup just click run. When I execute I get the following error message: "Cannot create a file when that file already exists."
Curiously enough the CSV file inside the source folder is copied to the Archive folder.
I was expecting only that the folder Plan 24-01-2020 would be moved to the folder Archive.
What I'm I doing wrong?
Because according to this tutorial the folder should be moved without any issues: https://www.tutorialgateway.org/move-directory-using-file-system-task-in-ssis/
I think there are two things you'll want to do here.
First, create an expression in the File System Task that sets OverwriteDestinationFile to TRUE.
Next, you'll want to slightly modify your Destination path. Instead of just \\Client\D$\Data Feed\Archive\, you'll probably want to specify your destination as \\Client\D$\Data Feed\Archive\Plan 24-01-2020\. Otherwise, it will just copy the contents of \\Client\D$\Data Feed\Plan 24-01-2020\ into \\Client\D$\Data Feed\Archive\ without creating the Plan 24-01-2020 sub-folder.

java.io.FileNotFoundException in Jmeter even if file is in bin folder itself

java.io.FileNotFoundException in Jmeter even if file is in bin folder itself
I have created a file in jmeter/bin Folder and then used it in Jmeter script without any path (only file name as it is already in bin folder)
Still I am getting error as java.io.FileNotFoundException
Filename path could be relative (to your .jmx file) or absolute (/home/username...).
Check your path for trailing spaces - jmeter doesnt know how to trim it.
Actually relative path in CSV Data Set Config (not in distributed test) is relative to test plan and not jmeter execution directory:
Filename Name of the file to be read. Relative file names are resolved with respect to the path of the active test plan.
You can also use absolute path or move your CSV file to same directory of your JMX files.

Can't find 'secure_file_priv' variable in my.cnf

I'm using mysql, and I want to enable saving queries to text files in any location. Currently, when I run the mysql command:
show variables like 'secure_file_priv';
I receive the value for 'secure_file_priv':
/var/lib/mysql-files/
I am able to save my queries to files in this location but nowhere else of course. (I'm also having trouble accessing this folder, even when I try to access it as root)
I found my 'my.cnf' file in '/etc/my.cnf', but it doesn't contain the variable 'secure_file_priv'!
I added it in myself as:
secure_file_priv=""
But this didn't do anything.
I also tried changing it through the mysql terminal, but it is a readonly variable, so I wasn't able to.
Where is this variable located and how can I change it to allow me to write the results of queries to files anywhere?

What UID is used by MySQL when a query is made?

I'm trying to read a file through MySQL's load_file command. But the result returned is Null and no error has occured in my query.
Since the file I'm trying to read is www-data protected, i'm wondering what my identity is in the server, if it isn't www-data.
It's pretty strange since I can use load_file to read /etc/passwd file.
The UID doesn't matter. The LOAD_FILE function will only read files that are world-readable. From the documentation:
The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.
So you can't use this to read a file that's only readable by the www-data user. You can use it with /etc/passwd because anyone can read that file.

File not found in MySQL data directory

I am trying to load an XML file into a table on my localhost MySQL server. Per MySQL 5.6 refman page I have my file loaded in the Data directory however I keep getting the error that my file is not found. I executed the SHOW VARIABLES WHERE Variable_Name LIKE "%dir" command and found where my data dictionary is located (C:\ProgramData\MySQL\MySQL Server 5.6\Data) and it's where I put my xml file but still get the same error:
mysql> USE test
Database changed
mysql> LOAD XML LOCAL INFILE 'testXML.xml'
-> INTO TABLE testxml
-> ROWS IDENTIFIED BY '<Data>';
ERROR 2 (HY000): File 'testXML.xml' not found (Errcode: 2 - No such file
or directory)
Any suggestions/direction would be appreciated. Thanks.
I remember having such a problem once and the problem was the spaces in the path name.
If really the file is at the right place and a file not found occur, I would highly suspect that the folder name 'MySQL Server 5.6' is the problem. You can validate this easily, put the file in another folder instead of the data dir and try adding/removing spaces to the folder name and see if it works.
An other possibility is that your folder is located in an Admin directory and that you don't have right to access.