HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How do you drop a corrupted INNODB database in MariaDB?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
corruptedyouinnodbdatabasedrophowmariadb

Problem

If you try to access a table in a database of type INNODB and MariaDB tells you it isn't here, you have a corrupted database.

(I am posting this question because all of the existing questions have been "closed" by various moderators and NONE of them have a real answer. They discuss the complexities of INNODB, and ultimately that you have to rebuild the entire database server through a torturous process.)

Solution

This may not work for everyone, but it did work for us on several occasions:

  • Stop the database (service mysql stop)



-
edit mysql.cnf so that under [mysqld] section it has the:

[mysqld] 
innodb_force_recovery = 1


-
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

[mysqld]
#innodb_force_recovery = 1


-
restart the database with the command:

service mysql start[ENTER]


Voila.

Now recreate the database and restore from your backup.

Thanks,
David

Code Snippets

[mysqld] 
innodb_force_recovery = 1
[mysqld]
#innodb_force_recovery = 1
service mysql start[ENTER]

Context

StackExchange Database Administrators Q#192484, answer score: 6

Revisions (0)

No revisions yet.