使用phpMyAdmin下载BLOB字段时会被删除

时间:2015-04-13 09:38:36

标签: phpmyadmin

Raw mysql-client :(好)

mysql> SELECT blobfield FROM `mytable` WHERE `id` = 46361 ;
{"example":"日本語...", "everything": "ok"}

phpMyAdmin>出口> SQL :(好)

(46361, 0x7b226578616d706c65223a223f3f3f2e2e2e222c202265766572797468696e67223a20226f6b227d);

phpMyAdmin>浏览>单击BLOB字段:(失败。仅部分保存)

{"example":"日本語...", "everythi

(编辑)curl(phpMyAdmin请求):

curl 'http://127.0.0.1:48001/tbl_get_field.php?db=develop&table=mytable&where_clause=%60mytable%60.%60id%60+%3D+46361&transform_key=data&sql_query=SELECT+id%2Cdata+FROM+%60mytable%60+WHERE+id%3D46361&token=removed' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0'
{"example":"日本語...", "everythi

(edit2)(在详细模式中,我发现了一个错误......)

< HTTP/1.1 200 OK
* Server nginx/1.6.2 is not blacklisted
< Server: nginx/1.6.2
< Date: Mon, 13 Apr 2015 10:45:08 GMT
< Content-Type: application/octet-stream
< Content-Length: **6453**
< Connection: keep-alive
< X-Powered-By: PHP/5.5.22-1~dotdeb.1
< Expires: Mon, 13 Apr 2015 10:45:08 +0000
< Cache-Control: no-store, no-cache, must-revalidate,  pre-check=0, post-check=0, max-age=0
< Pragma: no-cache
< Last-Modified: Mon, 13 Apr 2015 10:45:08 +0000
< Content-Description: File Transfer
< Content-Disposition: attachment; filename="mytable-data.bin"
< Content-Transfer-Encoding: binary

 * Excess found in a non pipelined read: excess = **1338**, size = 6453, maxdownload = 6453, bytecount = 0 .

有人有同样的问题吗?我猜phpMyAdmin正在发送错误的Content-Length值。

我的配置:

  • Mysql:5.6.23-log
  • phpMyAdmin:4.4.1.1
  • connection:utf8mb4_bin(从utf8_bin自动切换)
  • innodb:utf8_bin
  • 的nginx / 1.7.9
  • php:5.6.4-1 + deb.sury.org~trusty + 1 + mysqli

1 个答案:

答案 0 :(得分:0)

在文件&#34; tbl_get_field.php&#34;我找到了:

PMA_downloadHeader(
    $table . '-' .  $_GET['transform_key'] . '.bin',
    PMA_detectMIME($result),
    /*overload*/mb_strlen($result)
);

最后一行使用内部mb_internal_encoding()计算总长度。就我而言,它设置为UTF-8。

更改为:

/*overload*/mb_strlen($result, '8bit')

解决了我的问题。信息在这里:http://php.net/manual/en/function.mb-strlen.php#77040

添加到我的Dockerfile中的行:

RUN sed -i.bak s/mb_strlen\(\$result\)/mb_strlen\(\$result,\'8bit\'\)/g /data/http/tbl_get_field.php