MySQL中用于存储图像的数据类型是什么?

时间:2021-03-14 17:15:17

I need to store image and resume of user in the data base.

我需要在数据库中存储用户的图像和简历。

I am using mysql data base and php5. I need to know which data types I should use.

我正在使用mysql数据库和php5。我需要知道应该使用哪些数据类型。

And also how do I set a limit (maximum size) for uploaded data.

以及如何为上传的数据设置限制(最大大小)。

3 个解决方案

#1


26  

What you need, according to your comments, is a 'BLOB' (Binary Large OBject) for both image and resume.

根据您的评论,您需要的是图像和简历的“BLOB”(二进制大对象)。

#2


7  

Perfect answer for your question can be found on MYSQL site itself.refer their manual(without using PHP)

您可以在MYSQL网站上找到您的问题的完美答案。请参阅他们的手册(不使用PHP)

http://forums.mysql.com/read.php?20,17671,27914

http://forums.mysql.com/read.php?20,17671,27914

According to them use LONGBLOB datatype. with that you can only store images less than 1MB only by default,although it can be changed by editing server config file.i would also recommend using MySQL workBench for ease of database management

根据他们使用LONGBLOB数据类型。因此,只有默认情况下才能存储小于1MB的图像,尽管可以通过编辑服务器配置文件来更改它。我还建议使用MySQL workBench以便于数据库管理

#3


4  

This can be done from the command line. This will create a column for your image with a NOT NULL property.

这可以从命令行完成。这将为您的图像创建一个具有NOT NULL属性的列。

CREATE TABLE `test`.`pic` (
`idpic` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`caption` VARCHAR(45) NOT NULL,
`img` LONGBLOB NOT NULL,
PRIMARY KEY(`idpic`)
)
TYPE = InnoDB; 

From here

从这里

#1


26  

What you need, according to your comments, is a 'BLOB' (Binary Large OBject) for both image and resume.

根据您的评论,您需要的是图像和简历的“BLOB”(二进制大对象)。

#2


7  

Perfect answer for your question can be found on MYSQL site itself.refer their manual(without using PHP)

您可以在MYSQL网站上找到您的问题的完美答案。请参阅他们的手册(不使用PHP)

http://forums.mysql.com/read.php?20,17671,27914

http://forums.mysql.com/read.php?20,17671,27914

According to them use LONGBLOB datatype. with that you can only store images less than 1MB only by default,although it can be changed by editing server config file.i would also recommend using MySQL workBench for ease of database management

根据他们使用LONGBLOB数据类型。因此,只有默认情况下才能存储小于1MB的图像,尽管可以通过编辑服务器配置文件来更改它。我还建议使用MySQL workBench以便于数据库管理

#3


4  

This can be done from the command line. This will create a column for your image with a NOT NULL property.

这可以从命令行完成。这将为您的图像创建一个具有NOT NULL属性的列。

CREATE TABLE `test`.`pic` (
`idpic` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`caption` VARCHAR(45) NOT NULL,
`img` LONGBLOB NOT NULL,
PRIMARY KEY(`idpic`)
)
TYPE = InnoDB; 

From here

从这里