How to check your database for corruption: diferència entre les revisions
(→MySQL) |
(performance template) |
||
(3 revisions intermèdies per 3 usuaris que no es mostren) | |||
Línia 1: | Línia 1: | ||
Database corruption usually occurs as a result of a hardware (especially disk-based) failure, or when a disk becomes full. Typical symptoms are failure on login, with this message displayed: | {{Performance}}Database corruption usually occurs as a result of a hardware (especially disk-based) failure, or when a disk becomes full. Typical symptoms are failure on login, with this message displayed: | ||
Session Replace: Table './moodle/mdl_sessions2' is marked as crashed and should be repaired | Session Replace: Table './moodle/mdl_sessions2' is marked as crashed and should be repaired | ||
This problem mostly seems to affect MySQL | This problem mostly seems to affect MySQL. | ||
==MySQL== | ==MySQL== | ||
Línia 26: | Línia 26: | ||
Your mysql database server must be running when executing the mysqlcheck command. If there are problems with the tables, the auto-repair option will fix them as shown above. Note that the repair process can take a long time to complete. Re-run the command again to double-check that all is OK. | Your mysql database server must be running when executing the mysqlcheck command. If there are problems with the tables, the auto-repair option will fix them as shown above. Note that the repair process can take a long time to complete. Re-run the command again to double-check that all is OK. | ||
Individual Moodle tables can be checked by using MySQL Admin/phpMyAdmin | |||
Individual Moodle tables may be repaired using MySQL Admin/PHPMyAdmin as follows: | Individual Moodle tables may be repaired using MySQL Admin/PHPMyAdmin as follows: | ||
Línia 32: | Línia 34: | ||
# Click the Go button. | # Click the Go button. | ||
For example, to repair the Moodle log tables, type <code>REPAIR TABLE mdl_log</code> | For example, to repair the Moodle log tables, type <code>REPAIR TABLE mdl_log</code> | ||
In a similar manner to check the Moodle log table, type <code>CHECK TABLE MDL_LOG</code>. This will either say OK or tell you what is wrong. For example it may say "Table marked as crashed". | |||
==Other databases== | ==Other databases== | ||
Línia 43: | Línia 47: | ||
*[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 Database Journal article on repairing database corruption in MySQL] | *[http://www.databasejournal.com/features/mysql/article.php/10897_3300511_2 Database Journal article on repairing database corruption in MySQL] | ||
[[ | [[de:Wie man die Konsistenz der Moodle-Datenbank prüft]] |
Revisió de 10:03, 3 gen 2012
Database corruption usually occurs as a result of a hardware (especially disk-based) failure, or when a disk becomes full. Typical symptoms are failure on login, with this message displayed:
Session Replace: Table './moodle/mdl_sessions2' is marked as crashed and should be repaired
This problem mostly seems to affect MySQL.
MySQL
The problem can be repaired using the mysqlcheck command (the command you type is in bold and we assume the database name is 'moodle' and its type is MySQL):
#mysqlcheck -u moodleuser -p --auto-repair moodle Enter password: moodle.adodb_logsql OK moodle.mdl_assignment OK moodle.mdl_assignment_submissions OK ... moodle.mdl_log error : Table './moodle/mdl_log' is marked as crashed and should be repaired ... moodle.mdl_sessions2 error : Table './moodle/mdl_sessions2' is marked as crashed and should be repaired Repairing tables moodle_18_latest.mdl_log OK moodle_18_latest.mdl_sessions2 OK
Your mysql database server must be running when executing the mysqlcheck command. If there are problems with the tables, the auto-repair option will fix them as shown above. Note that the repair process can take a long time to complete. Re-run the command again to double-check that all is OK.
Individual Moodle tables can be checked by using MySQL Admin/phpMyAdmin
Individual Moodle tables may be repaired using MySQL Admin/PHPMyAdmin as follows:
- In the databases section, select the Moodle database.
- Click the SQL tab, then in the "Run SQL query/queries on database moodle" field type
REPAIR TABLE mdl_tablename
- Click the Go button.
For example, to repair the Moodle log tables, type REPAIR TABLE mdl_log
In a similar manner to check the Moodle log table, type CHECK TABLE MDL_LOG
. This will either say OK or tell you what is wrong. For example it may say "Table marked as crashed".
Other databases
As I said above, this issue normally only occurs with MySQL.
See also
- Forum discussion on a moodle database optimization script
- Performance Documentation on database repair and optimization
- Database Journal article on repairing database corruption in MySQL