2015-04-01 69 views
1

我創建使用數據庫:插入BLOB類型圖像MySQL數據庫

create table test.data(
    id int not null, 
    description varchar(255), 
    image blob not null, 
    primary key (id) 
); 

這個工作。然後,我嘗試使用將數據插入到表:

insert into test.data 
values(1, "Image one", LOAD_FILE('D:\Ecommerce\site\image1.jpg')); 

但我結束了一個錯誤,說column 'image' cannot be null

我如何可以將圖像到MySQL數據庫?我正在使用MySQL查詢瀏覽器和Windows 8.1。

回答

1

LOAD_FILE返回null。請嘗試以下操作:

  • 雙轉義文件路徑中的斜線(for Win)。
  • FILE權限必須明確授予您的mysql用戶。確保啓用了它。

如果它不工作檢查 LOAD_FILE_Doc ,並確保所有條件都滿足。

+0

雙重逸出文件路徑中的斜槓有效。 (..... load_file('C:\\ Users \\ Public \\ Pictures \\ image1.jpg'));)謝謝 – KMA 2015-04-02 01:18:48