I recently received an administrative email from my Zimbra mail server informing me that I had some corrupted tables in the MySQL database.
I confirmed this by logging into my Zimbra server and running the following command:
/opt/zimbra/mysql/bin/mysqlcheck –defaults-file=/opt/zimbra/conf/my.cnf -S /opt/zimbra/db/mysql.sock -A -C -s -p
This showed me that virtually every table in each database was in fact corrupted. The output from the command said that I could do a “REPAIR” or a dump/reload to fix them. Unfortunately, the REPAIR command doesn’t support the InnoDB engine so a dump and reload was the only option.
The commands to do this are fairly straight forward. Although, if you run a large site, you may want to take it offline first. Also, the above command mentions individual tables that are corrupt. I find it easier to just fix all the tables at once.
First, you need to dump a database:
mysqldump –defaults-file=/opt/zimbra/conf/my.cnf -S /opt/zimbra/db/mysql.sock -p mboxgroup1 > mboxgroup1.sql
Then reload it:
mysql –defaults-file=/opt/zimbra/conf/my.cnf –port=7306 -S /opt/zimbra/db/mysql.sock -D mboxgroup1 -p < mboxgroup1.sql
Repeat these steps for each database mentioned in the mysqlcheck output.
One thing to note is each command will prompt you for your MySQL root password. If you have forgotten yours, you can find it two different ways. The first is, the email sent to you by the system contains it. The second is by following these directions: Recovering Zimbra Passwords