SHOW VARIABLES LIKE 'MAX_ALLOWED_PACKET'; 为什么显示 Empty set
一定是你输入出错了,你少输一点,用这个吧 SHOW VARIABLES LIKE 'MAX%';
也同样结果。又有一个问题: 我的表如下: create table llc (ID int primary key, DATA LONGBLOB//保存二进制数据,来自于文件 ); 插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。 具体表现为:小于1M的LONGBLOB记录可以正常读出,而大于1M的就不能正常读出了。 怎么回事?
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 52 to server version: 4.0.11-gamma-max-nt-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW VARIABLES LIKE 'MAX_ALLOWED_PACKET'; +--------------------+---------+ | Variable_name | Value | +--------------------+---------+ | max_allowed_packet | 1047552 | +--------------------+---------+ 1 row in set (0.00 sec)mysql> >>>插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。你用什么访问数据库的??
load_image()函数 int load_image(MYSQL *conn,int id, FILE *.f) { char query[1024*100],buff[1023*10],*p; unsigned int from_len; int status; sprintf(query,"insert into images values(%d,'",id); p=query+strlen(query); while((from_len = fread(buf,1,sizeof(buf),f))>0) { if(p+(2*from_len)+3>query+sizeof(query)) { print_error(null,"image too big"); return(1); } p +=mysql_escape_string(p,buf,from_len); } (void) strcpy(p,"')"); status = mysql_query(conn,query); return(status); }
对了,数据表为 create table images ( image_id int not null primary key, image_data blob }
可以看到你的 MySQL 系统默认值
通常为 1M
你可以在 my.cnf / my.ini 文件中自己修改它[mysqld]
set-variable = max_allowed_packet = 8M
[WinMySQLAdmin]
Server=C:/mysql/bin/mysqld-nt.exe
是否添加了
[mysqld]
set-variable = max_allowed_packet = 8M
就可以了?
为什么显示
Empty set
SHOW VARIABLES LIKE 'MAX%';
我的表如下:
create table llc
(ID int primary key,
DATA LONGBLOB//保存二进制数据,来自于文件
);
插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。
具体表现为:小于1M的LONGBLOB记录可以正常读出,而大于1M的就不能正常读出了。
怎么回事?
Your MySQL connection id is 52 to server version: 4.0.11-gamma-max-nt-logType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> SHOW VARIABLES LIKE 'MAX_ALLOWED_PACKET';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1047552 |
+--------------------+---------+
1 row in set (0.00 sec)mysql>
>>>插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。你用什么访问数据库的??
int
load_image(MYSQL *conn,int id, FILE *.f)
{
char query[1024*100],buff[1023*10],*p;
unsigned int from_len;
int status;
sprintf(query,"insert into images values(%d,'",id);
p=query+strlen(query);
while((from_len = fread(buf,1,sizeof(buf),f))>0)
{
if(p+(2*from_len)+3>query+sizeof(query))
{
print_error(null,"image too big");
return(1);
}
p +=mysql_escape_string(p,buf,from_len);
}
(void) strcpy(p,"')");
status = mysql_query(conn,query);
return(status);
}
create table images
(
image_id int not null primary key,
image_data blob
}
如何在pl/sql中插入blob型的数据啊先谢谢啦
mysql> UPDATE tbl_name
SET blob_column=LOAD_FILE("/tmp/picture")
WHERE id=1;运行 LOAD_FILE 的要求:
1:
文件必须在服务器上,
2:
引用时必须用完全路径
3:
你必须有 FILE 权限
4:
读取的文件大小必须小于 max_allowed_packet