ANSWER #1
This feels clumsy doing this in Windows but here it goes. If you are able to login to mysql, then run this script
set MYSQL_USER=root
set MYSQL_PASS=rootpassword
set SQLSTMT=SELECT CONCAT('REPAIR TABLE ',table_schema,'.',table_name,';')
set SQLSTMT=%SQLSTMT% FROM information_schema.tables WHERE engine='InnoDB'
set MYSQL_CONN=-u%MYSQL_USER% -p%MYSQL_PASS%
echo %SQLSTMT%
mysql %MYSQL_CONN% -ANe"%SQLSTMT%" > C:\windows\InnoDBCheck.sql
After you run this script, add this to my.ini
[mysqld]
init-file=C:\windows\InnoDBCheck.sql
Then, restart mysql
net stop mysql
met start mysql
during the startup, just after crash recovery, the
Forgive me for such a crude solution since I have very little dealing with MySQL for Windows (that's not sarcasm, I am serious).
ANSWER #2
Here is something more serious
I just checked my MySQL 5.6.10 no-install ZIP file. It has innochecksum.
C:\>dir \MySQL_5.6.10\bin\i*
Volume in drive C has no label.
Volume Serial Number is 2C92-485B
Directory of C:\MySQL_5.6.10\bin
01/22/2013 07:05 PM 4,065,792 innochecksum.exe
01/22/2013 07:05 PM 3,706,880 innochecksum.pdb
2 File(s) 7,772,672 bytes
0 Dir(s) 160,596,770,816 bytes free
C:\>
Download that ZIP and try running that .
You could then collect all the .ibd
files with something like this:
cd "C:\Program Files\MySQL\MySQL 5.5\data"
dir *.ibd /s/b > C:\ibdfiles.bat
You can then edit C:\ibdfiles.bat
and prepend innochecksum against every filename.
Sorry this is not a full answer, but at least you can a hold of innochecksum.exe
InnoDB complains about wrong LSN because ib_logfile-s were deleted. You shouldn't have deleted those. But MySQL can survive after that. Next time InnoDB updates a page it will overwrite its LSN in the header and the error message will go away. Just wait till it starts (the error log shows neither successful nor unsuccessful start).
To get 100% clean tablespace you need to start MySQL with innodb_force_recovery=4, take mysqldump and restore it on a fresh instance of InnoDB (by fresh I mean you have to delete ibdata1, and all databases directories).
UPDATE:
At this point MySQL is started with innodb_force_recovery=x (x != 0)
Take dump of all databases:
# mysqldump --skip-lock-tables -A > alldb.sql
Check where MySQL keeps its files(in my case it's /var/lib/mysql/
):
# mysql -NBe "SELECT @@datadir"
/var/lib/mysql/
Stop MySQL
# mysqladmin shut
Move old MySQL files to safe place
# mv /var/lib/mysql /var/lib/mysql.old
Create new system database
# mkdir /var/lib/mysql
# mysql_install_db
Start MySQL
# /etc/init.d/mysql start
Restore the dump
# mysql < alldb.sql
Restore may take long time if the database is big.
Another trick may work in that case. Run ALTER TABLE ... ENGINE INNODB on each InnoDB table. It will rebuild all InnoDB indexes and thus the errors will go away.
Best Answer
This may not work for everyone, but it did work for us on several occasions:
edit mysql.cnf so that under [mysqld] section it has the:
Start the database (service mysql start) and in the logfile you will see it force loading the bad database/table
log into the database server as root: mysql -u root
run the command "show databases[ENTER]" to get a list of database
run he command "drop [dbname][ENTER]" where [thedb] is the database you need to drop. It will drop it but will complain that it cannot delete the directory ./[thedb].
Open a separate shell and go into /var/lib/mysql/[thedb]/ and remove the file(s) there.
Stop the database (service mysql stop)
Turn off the REPAIR mode by commenting out the line in mysql.cnf
restart the database with the command:
Voila.
Now recreate the database and restore from your backup.
Thanks, David