LOAD_FILE returns NULL - mysql

I am trying to insert an image into my MySQL server. I have done some research and it looks like the best way to do that is through LOAD_FILE(). However, LOAD_FILE() always returns null. I know there are 4 conditions for LOAD_FILE():
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.
I am currently using:
select LOAD_FILE('/Users/pricedb/Desktop/FolderName/imageName');
and it returns NULL
I have confirmed that all privileges are granted to the user. What does it mean that the file must be located on the server host? The server is being run off my local computer and and file is located there, so does that mean I am good on that?
Any advice would be greatly appreciated, I do not know why it's not returning a value.

I had the same issue.
Fond out that the file to be loaded, needs to be in the folder location where mysql/mariadb has privileges to read it.
It can be configured, BUT the data folder is already has access right.
In my case I copied my file to data folder: C:\Program Files\MariaDB 10.3\data
And than I just called it with full path:
select load_file('C:\\Program Files\\MariaDB 10.3\\data\\test.txt');

Here is my command on windows 7:
select load_file("C:/Program Files (x86)/MySQL/MySQL Workbench CE 6.0.7/images/hieuImages/a.jpg");
And it worked!
You maybe try to copy your images into that directory and select again in mysql.

"FILE" is an administrative privilege.
When you say that ALL privileges have been granted, does that include global administrative privileges too?
Here's the syntax http://dev.mysql.com/doc/refman/5.1/en/grant.html#grant-global-privileges, but I found "MySQL Workbench" GUI more helpful.
Check out OS file permissions, too.

Using MySQL Workbench 8.0:
In the Result Grid panel where you can see the rows and columns, right-click the cell that will hold the BLOB value (currently shown as NULL).
In the context menu that appears, select the first item: Open Value in Editor.
In the lower-left corner, there are two buttons. Click on: Load...
Browse to your image file.
The Binary tab is filled with the image's binary data.
Click: Apply. You'll return to the Result Grid panel again. Notice NULL has been replaced by BLOB.
Right-click BLOB and select Open Value in Editor once more.
You'll find a new tab at the top: Image. There you can preview the image you just added.
Greetings!

show variables like 'secure_file_priv';
Load file in this directory.
select load_file('directory_from_1');

Related

Change path to database in Microsoft Access 2013

I need to make something in the database. It was saved as .accdb files. I copied this from my workplace and now I want to edit it on my home computer, but when I've open these files and tried to see already made commands I got an error message that I have not a valid path. This error occurs while I want to open command forms for adding and deleting, which need to use other databases.
How can I change the path so my Access will know, where these files are stored on my computer?
Go to band option (Database) Tools.
Select Linked Table Manager (label is localized).
Mark the checkbox down-left: Always as for new location.
Click Mark All, then OK.
Input the folder name where the data file exists.

Pass Windows path to MySQL stored procedure

I have a stored procedure based on this question: How to store output of a stored procedure on to disk. For some reason I can't make it work with a Windows path. Always get the file writing error.
Any idea on how to pass the parameter?
Just tried this and struggled a bit too. Here's how I got it working:
On the folder(s) where MySQL will write files, make sure the appropriate privileges are given for write access. If security isn't a concern, a brute-force way of doing this is to right-click on the root folder, click on Properties -> Security tab, add "Everyone" and grant "Full Control". However, depending on where and why you are doing this you might need to be a lot more careful/selective...
Run the stored proc using something like:
CALL export_dynamic('C:/dump/test1.txt');
...or...
CALL export_dynamic('C:\\\\dump\\\\test2.txt');
(assuming C:\dump is the folder where files will be written with the permissions set as above.)
Note: There are other possible issues with disk space, anti-virus etc. but personally I didn't see anything like that (have Microsoft Security Essentials running).
The file name must be given as a literal string. On Windows, specify backslashes in path names as forward slashes or doubled backslashes.
As of MySQL 5.1.6, the character_set_filesystem system variable controls the interpretation of the file name.
It should be a permission issue... Check the folder permissions of the folder you are trying to write. Grant access to everyone.. Right Click on folder -> Properties -> Permissions -> Everyone -> Give full rights... now run the script.

Where does Chrome keep the SQLite Database file it writes things like stored passwords to?

Just like the title says, where does Chrome keep the SQLite file that holds things like stored passwords. I've found the follow database files and neither one of them hold the stored password information -
C:\Users\George\AppData\Local\Google\Chrome\User Data\Default\databases\Databases.db
and
C:\Users\George\AppData\Local\Google\Chrome\User Data\Default\Sync Data\SyncData.sqlite3
You are looking in the wrong places. By the way, the passwords are encrypted.
Use SQL-Lite viewer to view the contents of the file Login Data.
In Windows: LocalAppData\Google\Chrome\User Data\Default\Login Data
In Mac: ~/Library/Application Support/Google/Chrome/Default/Login Data
Once you find those files you can use Chrome password decryptor to see the password database if I remember corectly.

How works chrome.fileSystem.isRestorable?

chrome.fileSystem.isRestorable is a new part of the chrome.fileSystem API and it saif if a file can be restored with its entry or not. I've made many tests but something is wrong, when I tried to do :
chrome.storage.local.get(
["recentFileId1"],
function(recent) {
chrome.fileSystem.isRestorable(
recent["recentFileId1"],
function (isRestorable){
console.log(isRestorable);
});
});
It returns me true, even if the file has been deleted of my computer. recentFileId1 seems like a real id (many numbers and the path at the end, for example FD158F2A41037D17440C025C1CA5FE08:question.txt) and the file's restoration works if the file is still on my computer. When I tried to restore the file with an id of a deleted file it just returns nothing, no error.
So I want to know : did I use this feature wrong or something? It can work if I try to restore and see what is restored (if it returns nothing the file has been deleted), but I don't want to use a hack if the API is available.
Thanks.
This function is currently only available in the dev channel of Chrome, and should be released to stable in version 31.
What you're describing sounds like a bug, please file it at http://crbug.com. We should always return true or false. What the correct behavior in this case should be is not clear.
The intent of this function is to let an app know if it should provide UI to give the user access to previously opened files. If a file is restorable, it simply means the app still has permission to access the file.
We are reserving the right to limit when files are restorable. E.g. we might have an arbitrary upper limit to how many files can be restored, or the access might timeout after a few months, or we may give the user the option of not letting apps restore any files. isRestorable lets you know if access to a previously opened file is still available.
isRestorable is not intended to give information about how accessible the file still is. Local changes can impact this - e.g. the file might be deleted or the OS access permissions changed. It might still be there but be invisible to chrome and the app due to no read access to the containing folder.
Think about a recent documents menu. This could show files which were opened and since deleted. When the app restores a deleted app it would not work and would show an error to the user. At that point the user might go to their recycle bin or git checkout and replace the file.
Or the recent documents menu could just not show files which have been deleted.
Either way your app should not rely on isRestorable as an indication of whether a file entry can be regained and successfully used, you should handle restoreFile not restoring a file and giving an error, and handle access to the file having permission problems.

mysql not in my PATH for some reason

I've installed mysql on several macs and on one of them mysql is not in the path. If I export it it shows up in the path correctly, but upon reboot, disappears.
What should I do to get the machine to keep it in the path and what are the machines that DO have it in their path doing differently?
Any thoughts appreciated.
Check the /etc/profile file on the macs it's working on. The path file should be defined there, which would be for all users. The ~/.bash_profile mentioned is for an individual user.
You should see something similar to the previously mentioned
export PATH=/path/to/mysql_folder:$PATH
in this file, though it may be a bit buried. If you don't see PATH defined here, try /etc/environment. Failing this, I'm not sure where else OS X would define the path variable, but being a Unix system, there is a common file read by all profiles where it sets it.
Once you find it, compare the definition on the machines it works on to the one it doesn't, and edit accordingly. If it looks the same, then something's amiss, and you should let us know.
if it is linux you have to add this export to your profile script. if windows edit PATH in My Computer | Properties | Edit environmental variables
To one of your init files (such as /home/username/.bash_profile) add a line like:
export PATH=/path/to/mysql_folder:$PATH