Skip to content
Command Line Interface

How to repair crashed tables ​

WARNING

Applies to VoipNow 3 and newer!

After running out of disk space or after similar unexpected events, database tables often become corrupted. Depending on the table that has crashed, this can affect various system functions. To identify and fix the issue, follow the steps below.

Step-by-step guide ​

Identify the issue ​

Usually you can find this issue in the logs. For example, when Asterisk tries to read the call_history table, it reports a message similar to the one below.

bash
MySQL server error.SELECT SUM(duration) AS in_sum FROM call_history WHERE start >= '2015-01-01' AND start < ADDDATE('2015-01-01', INTERVAL 1 MONTH) AND flow = 'in'Table 'call_history' is marked as crashed and should be repaired

As a result, reports will not work.

bash
mysqlcheck -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow call_history

When the table is OK, the output is this:

voipnow.call_history                               OK

You can also perform a check on all tables (beware that this will create load on the system):

bash
mysqlcheck -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow

Fix the crashed table ​

To fix the table, simply log in to MySQL.

bash
mysql -u`cat /etc/voipnow/.sqldb | awk -F ":" '{print $2}'` -p`cat /etc/voipnow/.sqldb | awk -F ":" '{print $3}'` voipnow

And run:

bash
MariaDB [voipnow]> repair table call_history;
Last updated: Dec 11, 2025