我的MYSQL是5.7版本
binlog-format=row
我在用mysqlbinlog -v -v --base64-output=DECODE-ROWS 查看二进制文件时 所有的DML语句前面都有“###”3个这个符号,导致我没法进行数据恢复 要怎么解决啊 狼头大哥
binlog-format=row
我在用mysqlbinlog -v -v --base64-output=DECODE-ROWS 查看二进制文件时 所有的DML语句前面都有“###”3个这个符号,导致我没法进行数据恢复 要怎么解决啊 狼头大哥
解决方案 »
- wordpress 中的sql语句orderby 问题
- php连不上mysql,Warning: mysql_connect() [function.mysql-connect]: [2002] 由于连接方在一段时间
- mysql的字符串不带''在做查询的时候会有差别么?
- Operation failed: File doesn't exist mysql
- mysql update语句的问题
- MySql如何使用
- 跟踪mysql执行了哪些语句
- 在98下安装sql客户端后,新建sql注册,选择系统管理员给我分配的sql登陆信息(sql身份验证),并选择在连接是提示输入sql帐户信息后,注
- 自定义函数修改无效
- 优化数据查询,可以用什么工具来精确知道哪些字段可以建索引?
- mySQL两个表查询结果集组合
- 为什么使用mysql索引之后速度下降了80%?
可以用shell替换,或者直接用python替换里面的 ###3 字符串
protected $delimiter = ';';
protected $sCode;
protected $totalSize = 0;
protected $progressed = 0; public function __construct( $fileName, $code = 'utf-8' )
{
if( file_exists( $fileName )) {
$this->totalSize = filesize( $fileName );
$this->sqlFile = fopen($fileName, 'r');
}
$this->sCode = $code;
} public function __destruct()
{
if( $this->sqlFile )
fclose( $this->sqlFile );
} public function getProgress()
{
return ( $this->progressed / $this->totalSize );
} public function runSqlfile( PDO& $pdo, $callBack = null, $progressSize = 1024 )
{
$curr = $this->progressed;
while( $comm = $this->getNextCommand()) {
if( $comm ) {
$pdo->exec($comm);
if (($callBack != null) && (($this->progressed - $curr) >= $progressSize)) {
$curr = $this->progressed;
call_user_func_array($callBack, array($this->progressed, $this->totalSize));
}
}
}
if( $callBack != null ) {
call_user_func_array( $callBack, array( $this->progressed, $this->totalSize ));
}
} protected function getNextCommand()
{
$relCmd = '';
while (!feof($this->sqlFile)) { $comm = fgets($this->sqlFile);
$this->progressed += strlen( $comm ); if ($this->sCode != 'utf-8')
$comm = iconv($this->sCode, 'utf-8//TRANSLIT', $comm); $arrMatched = array();
if (preg_match('/^\s*[\r\n]+/i', $comm )) {
continue;
}
else if (preg_match('/^\s*delimiter\s+([^\s]*)\s*[\r\n]+/i', $comm, $arrMatched)) {
$this->delimiter = $arrMatched[1];
continue;
}
else if (preg_match('/^\s*--(.*)[\r\n]+/i', $comm )) {
continue;
}
else if (preg_match('/.*' . $this->delimiter. '\s*[\r\n]+$/i', $comm )) {
return $relCmd . $comm;
}
else {
$relCmd .= $comm;
}
}
return false;
}
}
说明一下,其中的
public function getProgress()
{
return ( $this->progressed / $this->totalSize );
}
以及runSqlfile中的 $callBack参数,都是用来显示处理进度用的,给用户呈现处理进度的,跟核心功能无关
mysqlbinlog gbichot2-bin.000007 gbichot2-bin.000008 | mysql