Mysql – How to repair thesql database

data-recoverydatabaseMySQL

I have a database server(Fedora 14) which mysql is running as the database server. Recently that server broke down and I was only able to get the database directory from the server.

I have tried to put that database directory which I was able to get from my broke down server into a mysql server which is running on another PC (also Fedora 14) but, only three tables had data and though the table names are shown, when I try to execute queries it says table not available except for three tables. I have more that 30 tables in that database.

Please tell me a way to recover those missing tables.

I have tried to repair tables as follow but it was not success,

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)

I think my tables are not MyISAM tables because when I run myisamchk *.MYI I got follwing results,

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

---------

.
.
.
.

Best Answer

You most make sure that you are running the same database version. Including the minor version. If the tables are MyISAM, than you can use myisamchk for recovery. See: http://dev.mysql.com/doc/refman/5.0/en/myisam-table-maintenance.html

Related Topic