遷移匯入ibd表資料正確的方式以及各種錯誤示例
一、問題提出
在mysql中使用獨享表空間,啟用innodb_file_per_table,把A庫表a遷移匯入B庫,怎麼樣匯入?
二、問題分析
把A庫表a遷移匯入B庫,可以用mysqldump,當然也可以複製表a.ibd檔案。複製表a.ibd檔案要有正確的順序,否則,會有各種錯誤。
三、操作步驟
正確的操作步驟應該是:在B庫,定義表-->刪除表空間(alter table ... discard tablespace;)-->複製*.ibd/*.cfg檔案-->匯入表空間(ALTER TABLE ... IMPORT TABLESPACE )
四、不按照定義表-->刪除表空間-->複製*.ibd/*.cfg檔案-->匯入表空間,會出現哪些錯誤呢?
請看如下操作:(1)直接複製a.ibd,a.frm到B庫的相應位置,報錯:
mysql> select * from a;
ERROR 1146 (42S02): Table 'test.a' doesn't exist
mysql> drop table a;
ERROR 1051 (42S02): Unknown table 'test.a'
mysql> create table a (id int,name varchar(30),age int);
ERROR 1813 (HY000): Tablespace for table '`test`.`a`' exists. Please DISCARD the tablespace before IMPORT. #不能建立表a
mysql> #######delete a.ibd a.frm ###### 這裡我刪除掉 a.ibd a.frm
mysql> select * from a;
ERROR 1146 (42S02): Table 'test.a' doesn't exist
mysql> drop table a;
ERROR 1051 (42S02): Unknown table 'test.a'
mysql> create table a (id int,name varchar(30),age int); ###能建立表a
Query OK, 0 rows affected (0.01 sec)
在mysql中使用獨享表空間,啟用innodb_file_per_table,把A庫表a遷移匯入B庫,怎麼樣匯入?
二、問題分析
把A庫表a遷移匯入B庫,可以用mysqldump,當然也可以複製表a.ibd檔案。複製表a.ibd檔案要有正確的順序,否則,會有各種錯誤。
三、操作步驟
正確的操作步驟應該是:在B庫,定義表-->刪除表空間(alter table ... discard tablespace;)-->複製*.ibd/*.cfg檔案-->匯入表空間(ALTER TABLE ... IMPORT TABLESPACE )
四、不按照定義表-->刪除表空間-->複製*.ibd/*.cfg檔案-->匯入表空間,會出現哪些錯誤呢?
請看如下操作:(1)直接複製a.ibd,a.frm到B庫的相應位置,報錯:
mysql> select * from a;
ERROR 1146 (42S02): Table 'test.a' doesn't exist
mysql> drop table a;
ERROR 1051 (42S02): Unknown table 'test.a'
mysql> create table a (id int,name varchar(30),age int);
ERROR 1813 (HY000): Tablespace for table '`test`.`a`' exists. Please DISCARD the tablespace before IMPORT. #不能建立表a
mysql> #######delete a.ibd a.frm ###### 這裡我刪除掉 a.ibd a.frm
mysql> select * from a;
ERROR 1146 (42S02): Table 'test.a' doesn't exist
mysql> drop table a;
ERROR 1051 (42S02): Unknown table 'test.a'
mysql> create table a (id int,name varchar(30),age int); ###能建立表a
Query OK, 0 rows affected (0.01 sec)
上面順序,不能建立表a,不能執行alter table a discard tablespace;
經典的1146錯誤,表空間遭到破壞,需要進行表空間的恢復。
五、問題總結:
要按照順序,正確操作。
經典的1146錯誤,表空間遭到破壞,需要進行表空間的恢復。
五、問題總結:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30393770/viewspace-2123734/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- jQuery匯入html的正確方式jQueryHTML
- mongodb資料遷移2種方式比較MongoDB
- MongoDB 資料遷移 備份 匯入(自用)MongoDB
- 外部表的另一種用途 資料遷移
- MYSQL資料匯出備份、匯入的幾種方式MySql
- Excel匯入null錯誤解決方式ExcelNull
- 物化檢視 VS 匯出/匯入 邏輯資料遷移
- 【imp】使用imp工具遷移資料時迂迴地排除特定表的匯入
- 海量資料遷移之外部表載入
- oracle 各種遷移總結Oracle
- 資料庫遷移的幾個方式資料庫
- 【資料遷移】使用傳輸表空間遷移資料
- imp 匯入 FK (Foreign Key) 導致資料不能正確匯入處理
- ClickHouse學習系列之八【資料匯入遷移&同步】
- mysql匯入資料亂碼錯誤一則MySql
- 一個簡單的MySQL資料遷移示例MySql
- 資料泵引數彙總與各種匯出匯入規則
- 使用prebuilt table 方式遷移資料UI
- 用觸發器返回錯誤提示,糾正錯誤資料錄入觸發器
- JavaScript 中錯誤正確處理方式,你用對了嗎?JavaScript
- Progress資料表的匯入匯出
- 匯入CSS的三種方式CSS
- 資料表內容遷移?
- imp匯入資料庫表時浮現ORA-01658錯誤資料庫
- 用begin backup的方式遷移資料庫資料庫
- 用匯入匯出誇平臺遷移所有資料( Move a Database Between Platforms)DatabasePlatform
- 海量資料遷移之使用分割槽並行切分匯入並行
- 資料遷移(1)——通過資料泵表結構批量遷移
- oracle 表空間下資料檔案遷移的三種方法Oracle
- 正確理解 PHP 錯誤資訊(轉)PHP
- 解決遷移資料庫錯誤,索引長度過長資料庫索引
- 檢測資料庫遷移準確性資料庫
- BIEE 目錄遷移(資料夾)方式
- Flutter 錯誤捕獲的正確姿勢Flutter
- mysqldump匯入匯出表資料MySql
- 資料泵匯出匯入表
- 詳細分析 Java 中啟動執行緒的正確和錯誤方式Java執行緒
- laravel 資料庫遷移時報錯Laravel資料庫