Tag: myisamchk

  • Can’t open and lock privilege tables: Table ./mysql/db is marked as crashed

    On a Cpanel Server, MySQL did not start. I checked the error log in /var/lib/mysql folder, and found the following error in MySQL log file /var/log/mysqld.log

    2023-03-10T18:13:26.405453Z 0 [ERROR] /usr/sbin/mysqld: Table './mysql/db' is marked as crashed and should be repaired
    2023-03-10T18:13:26.405465Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and should be repaired
    2023-03-10T18:13:26.405471Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
    2023-03-10T18:13:26.405486Z 0 [ERROR] Aborting
    

    It says “db” table in “mysql” database got corrupted. To fix, I run following

    cd /var/lib/mysql/mysql
    myisamchk -r db
    

    Now restart MySQL with the command

    systemctl restart mysqld
    

    Back to MySQL Repair

  • myisamchk: Argument list too long

    When repairing a large database, i got following error

    [root@server root]# myisamchk --silent --force --fast --update-state \
              --key_buffer_size=64M --sort_buffer_size=64M \
              --read_buffer_size=1M --write_buffer_size=1M /var/lib/mysql/databasename/*.MYI
    -bash: /usr/bin/myisamchk: Argument list too long
    

    To fix the error, run

    SOLUTION 1

    find /backup/mysql/bizhat_s2 -type f -print0 -name '*.MYI' | xargs -0 myisamchk --force --fast --update-state --key_buffer_size=64M --sort_buffer_size=64M --read_buffer_size=1M --write_buffer_size=1M
    

    SOLUTION 2

    find /var/lib/mysql/databasename -name *.MYI -exec myisamchk -r {} \;
    

    See MySQL