Jump to content


dylanfrancis

Member Since 08 Feb 2016
Offline Last Active Feb 08 2016 09:24 PM

Posts I've Made

In Topic: MySQL database

08 February 2016 - 09:12 PM

Repairing tables with mysqlcheck or another variant to learn helpful topics about mysql databases

 

https://social.msdn....m=sqldataaccess

http://www.sqlserver...894-2893-1.aspx

 

But in case your corruption can't be overcome, then I would suggest you more powerful instrument for such cases https://mysql.recoverytoolbox.com/ Recovery Toolbox for MySQL

 

If you, by any chance, forgot to create backup, you should do more work as the following:

  1. Edit my.cnf (usually located in /etc/my.cnf) and add this line into [mysqld] section
     

innodb_force_recovery=4

  1. Restart mysql (e.g: /etc/init.d/mysqld restart)
  2. Your MySQL log should tell you which table is corrupt. You can dump the table using “SELECT … INTO OUTFILE …” from mysql console or using tool like mysqldump
    • Example using MySQL query (you also need to dump the schema later)
       

mysql> SELECT * FROM corrupted_table INTO OUTFILE ‘/path/to/file’

  • Example using mysqldump
     

root# mysqldump –opt -u uname -p dbname corrupted_tablename > /path/to/out.sql

  1. Go back to my.cnf and comment the line you wrote from step #1
  2. Go intoMySQL console and drop the corrupted table
     

mysql> DROP TABLE corrupted_tablename;

  1. Import data dump, for sql dump you can use:
     

root# mysql -u uname -p < /path/to/out.sql

  1. Go back into mysql console, check and optimize all tables
  2. Done