5

Workbench 6.0.2.

I have inserted the image using the following query:

create table images (ID int,Image BLOB);  
insert into images values (1,load_file('C:\Users\PEL_AY\Desktop\1.jpg') );

But the problem is how to view the image stored image database using load_file

Do I need a front-end to view the image?

Divya
  • 1,469
  • 1
  • 13
  • 25
  • possible duplicate - : http://stackoverflow.com/questions/7793009/how-to-retrieve-images-from-mysql-database-and-display-in-an-html-tag – Divya Mar 15 '14 at 11:43
  • THank you... helped me a lot. @A5l-lE5 would you recommend me to store the image in the database using the BLOB ??? cause i have seen in some websites that storing image in database using BLOB is a bad idea. –  Mar 15 '14 at 11:50
  • yeah you can use to store the path of the image in the data base and store the images in your folder.it will be eazy to get that path as a string from Database and get set that path in the img src so that it will directly pick that image from that path – Divya Mar 15 '14 at 11:52
  • Do MySQL workbench support any functions to view the stored image. May be some kina query.??? "LIke viewing the image on a html page". –  Mar 15 '14 at 11:59
  • no i MySql workbench is just a platform to connect to the database and get queried data.and you wanted to get images then save them in a folder instead and pick them from there simple – Divya Mar 15 '14 at 12:03

1 Answers1

9

You can embed image data just like any data in a MySQL table. For binary data you usually would use a BLOB column data type. MySQL Workbench has a built-in editor for binary data, which you can open via the result grid context menu:

enter image description here

This editor allows to view text, hex binary values and images (limited to those formats the platform can show, e.g. on Windows bmp, gif, png, jpg and a few more).

enter image description here

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
  • Hey @Mike Lischke, I guess there two datatypes for image storing. The BLOB and the LONGBLOG. so which would you recommend me to use. –  Mar 16 '14 at 11:16
  • A quick search for "mysql longblob" gives you immediately the link to the MySQL documentation as the very first hit. That explains the blob types. Which type you choose entirely depends on what you want to store. – Mike Lischke Mar 16 '14 at 15:32
  • Hi, i tried the above procedure..the image gets loaded and there are values in the text and binary fields..however when i do view in i can't see any image there in mysql workbench – pranay Aug 25 '15 at 16:24
  • got the mistake..converted the datatype from BLOB to MEDIUMBLOB and now the image is visible – pranay Aug 25 '15 at 16:30