Home > other >  LOAD_FILE returns only null
LOAD_FILE returns only null

Time:08-14

I want to insert the image to the database with this query:

SELECT LOAD_FILE('/Users/juliagaskevich/cool-background.svg');

I checked that:

  • File size < max_allowed_packet.
  • File has read, write and execute permissions to everyone.
  • The user, what I'm using to execute the query has FILE privilege.
  • mysql> show variables like "secure_file_priv" returns NULL.

System configuration:

macOS Monterey, version 12.5, chip Apple M1

MySQL Ver 8.0.29 for macos12 on arm64 (MySQL Community Server - GPL) MySQL Config:

[mysqld]
user = mysql_deamon
slow_query_log_file = my-slow-query.log
slow-query-log
log-queries-not-using-indexes
general_log_file = my-GENERAL.log
max_allowed_packet = 1073741824

CodePudding user response:

1.vi my.cnf

secure-file-priv=/mysql/dataload(Change /mysql/dataload to your own directory.)

2.restart mysql service

CodePudding user response:

The statement SELECT LOAD_FILE(...) delivers one string. To INSERT, use the statement LOAD DATA INFILE ...

  • Related