你所需的是,
读入二进制文件,
然后将文件中必要的数据进行转义处理详细内容参看 FAQ
如何Mysql的命令行插blob数据..
http://expert.csdn.net/Expert/FAQ/FAQ_Index.asp?id=71276

解决方案 »

  1.   

    使用LOAD_FILE是读入文件,可以要把LOAD_FILE读入的数据输出到文件又该用什么语句?
      

  2.   

    还有默认的max_allowed_packet是多少?
      

  3.   

    输出需要用编程实现SHOW VARIABLES LIKE 'MAX_ALLOWED_PACKET'
    可以看到你的 MySQL 系统默认值
    通常为 1M
    你可以在 my.cnf / my.ini 文件中自己修改它[mysqld]
    set-variable = max_allowed_packet = 8M
      

  4.   

    我的my.ini文件中只有
    [WinMySQLAdmin]
    Server=C:/mysql/bin/mysqld-nt.exe
    是否添加了
    [mysqld]
    set-variable = max_allowed_packet = 8M
    就可以了?
      

  5.   

    SHOW VARIABLES LIKE 'MAX_ALLOWED_PACKET';
    为什么显示
    Empty set
      

  6.   

    一定是你输入出错了,你少输一点,用这个吧
    SHOW VARIABLES LIKE 'MAX%';
      

  7.   

    也同样结果。又有一个问题:
    我的表如下:
    create table llc
    (ID int primary key,
     DATA LONGBLOB//保存二进制数据,来自于文件
    );
    插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。
    具体表现为:小于1M的LONGBLOB记录可以正常读出,而大于1M的就不能正常读出了。
    怎么回事?
      

  8.   

    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>
    >>>插入是正确的,可是把已经插入的数据再读出生成为文件的时候,就有问题了。你用什么访问数据库的??
      

  9.   

    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);
    }
      

  10.   

    对了,数据表为
    create table images
    (
      image_id int not null primary key,
      image_data blob
    }
      

  11.   

    请问各位兄弟姐妹:
    如何在pl/sql中插入blob型的数据啊先谢谢啦
      

  12.   

    我也着好在找这个问题,发现   shuixin13(犬犬(心帆))  已经给出了方法,现在copy如下:
    mysql> UPDATE tbl_name
               SET blob_column=LOAD_FILE("/tmp/picture")
               WHERE id=1;运行 LOAD_FILE 的要求:
    1:
    文件必须在服务器上,
    2:
    引用时必须用完全路径
    3:
    你必须有 FILE 权限
    4:
    读取的文件大小必须小于 max_allowed_packet