percona 5.7.13 5.7.14 MYSQLDUMP备份完成后不能呢导回去,
文件一大了非常麻烦,最近遇到这样的问题。
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.sql
Enter password:
ERROR at line 63: DELIMITER must be followed by a 'delimiter' character or string
ERROR 1064 (42000) at line 64: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4
其实这里就是DELIMITER 后面的;;解析了,只要把;;转变为$$ 就好了.
[root@testmy client]# sed -i "s/;;/$$/g" log.sql
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.log
Enter password:
[root@testmy client]#
当然我这里是测试库,如果真的是线上库量非常大作sed谈何容易。所以决定从mysqldump下手改一下标识即可。
下面是修改部分,因为MYSQLDUMP是独立的工具,这些函数全是static函数,可以放心修改,如果是外部函数真
还不敢改,修改源码的client/mysqldump.c 如下部分修改了:
static uint dump_events_for_db(char *db)
2547 fprintf(sql_file,
2548 "DELIMITER ;;\n"
2549 "%s ;;\n"
2550 "DELIMITER ;\n",
修改为
static uint dump_events_for_db(char *db)
2547 fprintf(sql_file,
2548 "DELIMITER $$\n"
2549 "%s $$\n"
2550 "DELIMITER ;\n",
static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
MYSQL_ROW *show_trigger_row,
const char *table_name)
3247 fprintf(sql_file,
3248 "DELIMITER ;;\n"
3249 "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
3250 "/*!50003 CREATE */ ",
3251 (*show_trigger_row)[6]);
修改为:
3247 fprintf(sql_file,
3248 "DELIMITER $$\n"
3249 "/*!50003 SET SESSION SQL_MODE=\"%s\" */$\n"
3250 "/*!50003 CREATE */ ",
3251 (*show_trigger_row)[6]);
static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
const char *db_name,
const char *db_cl_name)
3334 fprintf(sql_file,
3335 "DELIMITER ;;\n"
3336 "/*!50003 %s */;;\n"
3337 "DELIMITER ;\n",
3338 (const char *) (query_str != NULL ? query_str : row[2]));
修改为:
3334 fprintf(sql_file,
3335 "DELIMITER $$\n"
3336 "/*!50003 %s */$$\n"
3337 "DELIMITER ;\n",
3338 (const char *) (query_str != NULL ? query_str : row[2]));
最后需要重新cmake一下make编译一下不需要make install 把mysqldump 拷贝到相应的目录即可
修改后
[root@testmy client]# more log.log |grep '$$'
DELIMITER $$
end */$$
DELIMITER $$
end $$
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.log
Enter password:
[root@testmy client]#
不会报错了。
</log.log
</log.log
</log.sql
文件一大了非常麻烦,最近遇到这样的问题。
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.sql
Enter password:
ERROR at line 63: DELIMITER must be followed by a 'delimiter' character or string
ERROR 1064 (42000) at line 64: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4
其实这里就是DELIMITER 后面的;;解析了,只要把;;转变为$$ 就好了.
[root@testmy client]# sed -i "s/;;/$$/g" log.sql
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.log
Enter password:
[root@testmy client]#
当然我这里是测试库,如果真的是线上库量非常大作sed谈何容易。所以决定从mysqldump下手改一下标识即可。
下面是修改部分,因为MYSQLDUMP是独立的工具,这些函数全是static函数,可以放心修改,如果是外部函数真
还不敢改,修改源码的client/mysqldump.c 如下部分修改了:
static uint dump_events_for_db(char *db)
2547 fprintf(sql_file,
2548 "DELIMITER ;;\n"
2549 "%s ;;\n"
2550 "DELIMITER ;\n",
修改为
static uint dump_events_for_db(char *db)
2547 fprintf(sql_file,
2548 "DELIMITER $$\n"
2549 "%s $$\n"
2550 "DELIMITER ;\n",
static void dump_trigger_old(FILE *sql_file, MYSQL_RES *show_triggers_rs,
MYSQL_ROW *show_trigger_row,
const char *table_name)
3247 fprintf(sql_file,
3248 "DELIMITER ;;\n"
3249 "/*!50003 SET SESSION SQL_MODE=\"%s\" */;;\n"
3250 "/*!50003 CREATE */ ",
3251 (*show_trigger_row)[6]);
修改为:
3247 fprintf(sql_file,
3248 "DELIMITER $$\n"
3249 "/*!50003 SET SESSION SQL_MODE=\"%s\" */$\n"
3250 "/*!50003 CREATE */ ",
3251 (*show_trigger_row)[6]);
static int dump_trigger(FILE *sql_file, MYSQL_RES *show_create_trigger_rs,
const char *db_name,
const char *db_cl_name)
3334 fprintf(sql_file,
3335 "DELIMITER ;;\n"
3336 "/*!50003 %s */;;\n"
3337 "DELIMITER ;\n",
3338 (const char *) (query_str != NULL ? query_str : row[2]));
修改为:
3334 fprintf(sql_file,
3335 "DELIMITER $$\n"
3336 "/*!50003 %s */$$\n"
3337 "DELIMITER ;\n",
3338 (const char *) (query_str != NULL ? query_str : row[2]));
最后需要重新cmake一下make编译一下不需要make install 把mysqldump 拷贝到相应的目录即可
修改后
[root@testmy client]# more log.log |grep '$$'
DELIMITER $$
end */$$
DELIMITER $$
end $$
[root@testmy client]# /mysqldata/mysql3308/bin/mysql -uroot -p<log.log
Enter password:
[root@testmy client]#
不会报错了。
</log.log
</log.sql