How to Fix MySQL Error 1548: “Cannot load from mysql.proc. The table is probably corrupted” – Database Recovery Guide


1 views

When working with MySQL 5.1 (specifically version 5.1.58 as shown in the logs), you might encounter this error when trying to access stored procedures:

ERROR 1548 (HY000): Cannot load from mysql.proc. The table is probably corrupted

This typically occurs when:

  • Attempting to create/modify/delete stored procedures
  • Running mysql_upgrade
  • After improper server shutdown
  • During database migration between versions

From the provided logs, we can see several key indicators:

mysql> REPAIR TABLE mysql.proc;
+------------+--------+----------+-----------------------------------------------------------------------------------------+
| Table      | Op     | Msg_type | Msg_text                                                                                |
+------------+--------+----------+-----------------------------------------------------------------------------------------+
| mysql.proc | repair | error    | Can't change permissions of the file '/srv/mysql/myDB/mysql/proc.MYD' (Errcode: 1) |
| mysql.proc | repair | status   | Operation failed                                                                        |
+------------+--------+----------+-----------------------------------------------------------------------------------------+

Notice the permission issues despite correct file permissions shown in ls output:

$ ls -l /srv/mysql/myDB/mysql/proc.MYD
-rwxrwxrwx 1 mysql root 3983252 2012-02-03 22:51 /srv/mysql/myDB/mysql/proc.MYD

Step 1: Manual Table Repair

First try these commands while MySQL is running:

mysql> CHECK TABLE mysql.proc;
mysql> REPAIR TABLE mysql.proc;

If that fails (as it did in our case), proceed to offline repair.

Step 2: Offline Repair with mysqlcheck

# Stop MySQL first
sudo service mysql stop

# Run check with forced repair
mysqlcheck --repair --databases mysql --tables proc \
--socket=/srv/mysql/sockets/mysql-myDB.sock \
--port=3700 -u root -p

# Alternative if above fails
myisamchk -r /srv/mysql/myDB/mysql/proc.MYI
myisamchk --safe-recover /srv/mysql/myDB/mysql/proc.MYI

Step 3: Rebuild the proc Table

If repair attempts fail, we need to rebuild:

# Create backup
mysqldump --no-data mysql proc > proc_structure.sql
mysqldump mysql proc > proc_data.sql

# Drop and recreate
mysql -e "DROP TABLE mysql.proc;"
mysql < proc_structure.sql

# Restore data if possible
mysql < proc_data.sql

Step 4: Final Verification

mysql> SHOW CREATE TABLE mysql.proc\G
mysql> SELECT COUNT(*) FROM mysql.proc;
  • Regularly back up your mysql database schema
  • Consider upgrading from MySQL 5.1 (EOL since Dec 2013)
  • Implement proper shutdown procedures
  • Monitor disk space and I/O errors

For production systems where downtime must be minimized:

# Create temporary procedure table
CREATE DATABASE mysql_recovery;
CREATE TABLE mysql_recovery.proc LIKE mysql.proc;
INSERT INTO mysql_recovery.proc SELECT * FROM mysql.proc;

# Point MySQL to alternative table (temporary fix)
SET GUMN proc_table='mysql_recovery.proc';

When working with MySQL 5.1 (particularly common in older Ubuntu systems like 11.10), you might encounter this frustrating error when trying to access stored procedures:

ERROR 1548 (HY000): Cannot load from mysql.proc. The table is probably corrupted

From the provided logs, we can see several important details:

$ mysql -V
mysql  Ver 14.14 Distrib 5.1.58, for debian-linux-gnu (x86_64)
$ lsb_release -a
Ubuntu 11.10

The standard repair attempts failed:

mysql> REPAIR TABLE mysql.proc;
| mysql.proc | repair | Error | Can't change permissions of the file (Errcode: 1) |

Here's the step-by-step approach that actually works:

# Stop MySQL server first
sudo service mysql stop

# Backup the corrupted files
sudo cp /srv/mysql/myDB/mysql/proc.frm /tmp/proc.frm.bak
sudo cp /srv/mysql/myDB/mysql/proc.MYD /tmp/proc.MYD.bak
sudo cp /srv/mysql/myDB/mysql/proc.MYI /tmp/proc.MYI.bak

# Remove the corrupted files
sudo rm /srv/mysql/myDB/mysql/proc.*

# Recreate the proc table
sudo mysql_install_db --user=mysql --datadir=/srv/mysql/myDB

# Start MySQL
sudo service mysql start

# Run mysql_upgrade
sudo mysql_upgrade -uroot -p --force

If the above doesn't work, try this more comprehensive method:

# Dump all procedures first (if possible)
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt \
    -uroot -p your_database > procedures.sql

# Rebuild mysql system tables
sudo mysql_install_db --user=mysql --datadir=/srv/mysql/myDB --force

# Restore procedures
mysql -uroot -p < procedures.sql

To avoid future occurrences:

  • Regularly backup the mysql.proc table
  • Consider upgrading to a newer MySQL version
  • Implement proper filesystem permissions (avoid 777)

The presence of a proc.TMD file suggests an interrupted operation:

-rwxrwxrwx 1 mysql root 3977704 2012-02-21 13:23 proc.TMD

This temporary file should be removed after resolving the issue.