我有一台数据库服务器(Fedora 14),mysql 作为数据库服务器运行。最近该服务器崩溃了,我只能从该服务器获取数据库目录。
我尝试将我从崩溃的服务器获取的数据库目录放入在另一台 PC(也是 Fedora 14)上运行的 mysql 服务器中,但只有三个表有数据,虽然显示了表名,但当我尝试执行查询时,它显示除了三个表之外,其他表都不可用。我的数据库中有 30 多个表。
请告诉我一种恢复那些丢失的表格的方法。
我曾尝试按如下方法修复表格,但没有成功,
mysql> show tables;
+-----------------------+
| Tables_in_ofm_mnu_jvs |
+-----------------------+
| Company |
| CostCenters |
| CostVariable |
| Des_Note |
| EDN_Main |
| EDN_Sub |
| Factory |
| ICMT_Main |
| ICMT_Sub |
| IMT_Main |
| IMT_Sub |
| ItemLedger |
| JC_InOutCrop |
| JC_Main |
| Ledger |
| Log |
| OLD_Stock |
| SRN_Main |
| SRN_Sub |
| St_BFG |
| St_FGS |
| St_OGS |
| St_OLS1 |
| St_OLS2 |
| St_OLS3 |
| St_OLS4 |
| St_OLS5 |
| St_RAW |
| St_RDS |
| St_SPG |
| SysUpdate |
| Vw_AllStock |
| Vw_AllStokMove |
| Vw_AllStokMove1 |
| Vw_ExcropBalance |
| Vw_JCSummary |
| a_user |
| act_months |
| batchno |
| certification |
| e_email |
| grn_main |
| grn_sub |
| item_code |
| item_grade |
| mtn |
| san |
| stocktype |
| supplier |
| uom |
| zc_Block |
| zc_Cetification |
| zc_FarmerAccount |
| zc_FarmerCer |
| zc_FarmerCompany |
| zc_FarmerCrop |
| zc_FarmerReg |
| zc_IcsYear |
| zc_Society |
| zc_temfar_crop |
| zc_temfar_main |
| zc_user |
+-----------------------+
62 rows in set (0.00 sec)
mysql> repair table Company;
+---------------------+--------+----------+-------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+---------------------+--------+----------+-------------------------------------------+
| ofm_mnu_jvs.Company | repair | Error | Table 'ofm_mnu_jvs.Company' doesn't exist |
| ofm_mnu_jvs.Company | repair | status | Operation failed |
+---------------------+--------+----------+-------------------------------------------+
2 rows in set (0.00 sec)
我认为我的表不是 MyISAM 表,因为当我运行 myisamchk *.MYI 时,我得到了以下结果,
myisamchk *.MYI
Checking MyISAM file: act_months.MYI
Data records: 2 Deleted blocks: 0
myisamchk: warning: 1 client is using or hasn't closed the table properly
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check record links
MyISAM-table 'act_months.MYI' is usable but should be fixed
---------
Checking MyISAM file: OLD_Stock.MYI
Data records: 115375 Deleted blocks: 0
myisamchk: warning: 7 clients are using or haven't closed the table properly
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check data record references index: 2
- check record links
MyISAM-table 'OLD_Stock.MYI' is usable but should be fixed
---------
Checking MyISAM file: zc_IcsYear.MYI
Data records: 0 Deleted blocks: 0
- check file-size
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check record links
[root@localhost ofm_mnu_jvs]# myisamchk *.frm
myisamchk: error: 'act_months.frm' is not a MyISAM-table
---------
myisamchk: error: 'a_user.frm' is not a MyISAM-table
---------
myisamchk: error: 'batchno.frm' is not a MyISAM-table
---------
myisamchk: error: 'certification.frm' is not a MyISAM-table
---------
myisamchk: error: 'Company.frm' is not a MyISAM-table
---------
myisamchk: error: 'CostCenters.frm' is not a MyISAM-table
---------
myisamchk: error: 'CostVariable.frm' is not a MyISAM-table
---------
myisamchk: error: 'Des_Note.frm' is not a MyISAM-table
---------
myisamchk: error: 'EDN_Main.frm' is not a MyISAM-table
---------
myisamchk: error: 'EDN_Sub.frm' is not a MyISAM-table
---------
myisamchk: error: 'e_email.frm' is not a MyISAM-table
---------
myisamchk: error: 'Factory.frm' is not a MyISAM-table
---------
.
.
.
.
答案1
您一定要确保您运行的是同一数据库版本。包括次要版本。如果表是 MyISAM,则您可以将其用于myisamchk
恢复。请参阅:http://dev.mysql.com/doc/refman/5.0/en/myisam-table-maintenance.html