0
我使用批處理文件從server1複製數據庫到server2。用於導出的MySQL批處理文件調用刷新表
Step 1: call stored procedure for FLUSH TABLES table1,table2, ..., table1000 FOR EXPORT;
Step 2: copy files .ibd and .cfg to temp directory and archive this
Step 3: unlock tables;
問題是第一步 - 文件.cfg被創建,然後刪除,但解鎖表不被調用。爲什麼?創建.CFG並立即消失文件,我沒有時間來複制
.bat文件命令:
mysql -u %db_user% -p%db_password% %db_name% --default-character-set=utf8 < stored_proc_flush_tables.sql
文件stored_proc_flush_tables.sql:
DROP PROCEDURE IF EXISTS stored_proc_flush_tables;
DELIMITER //
CREATE PROCEDURE stored_proc_flush_tables
(
)
BEGIN
DECLARE t_name BLOB;
DECLARE tmp_query BLOB;
DECLARE done_tables INT DEFAULT 0;
DECLARE cursor_tables CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_schema=DB_NAME;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done_tables = 1;
SET @table_name = '';
SET @tmp_query = '';
OPEN cursor_tables;
tables_loop: LOOP
FETCH cursor_tables INTO t_name;
IF done_tables = 1 THEN
LEAVE tables_loop;
END IF;
SET @tmp_query = CONCAT_WS('', @tmp_query, ',', t_name);
END LOOP;
CLOSE cursor_tables;
SET @tmp_query = TRIM(LEADING ',' FROM @tmp_query);
SET @tmp_query = CONCAT_WS('', 'FLUSH TABLES', ' ', @tmp_query, ' ', 'FOR EXPORT');
PREPARE stmt FROM @tmp_query;
EXECUTE stmt;
END //
DELIMITER ;
call stored_proc_flush_tables();
.CFG文件創建和立即消失,我沒有時間複製它們