Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

mysql - LOAD_FILE returns NULL

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():

  1. The file must be located on the server host
  2. You must specify the full path name to the file, and you must have the FILE privilege.
  3. The file must be readable by all and its size less than max_allowed_packet bytes.
  4. 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...