使用 phpMyAdmin 下载时 BLOB 字段被剪切

BLOB field is cut when download using phpMyAdmin

原始 mysql-客户端:(好)

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 值。

我的配置:

在文件 "tbl_get_field.php" 中我发现:

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