MySQL error repair: Table crashed repair

问题一 Table xx is marked as crashed and last (automatic?) repair failed

A developer found me and said that the database was broken and could not be connected to the database. I checked the MySQL error log and reported the following error:

Error: Table './db_name/table_name' is marked as crashed and last (automatic?) repair failed

repair

1. Stop MySQL first: service mysqld stop
2. Enter the file storage directory of the MySQL database, such as cd /data/mysql_data/xx_db
and execute the following command:

myisamchk --safe-recover -f -r *.MYI

After the execution is complete, for the sake of safety, we need to change the file permissions back to the MySQL running account (check it by ourselves), such as mysql:

chown -R mysql:mysql .

3. Start MySQL: service mysqld start
4. Finally, execute the automatic repair optimization command again to solve:

mysqlcheck --auto-repair --optimize --all-databases -p密码

问题二 /usr/local/mysql/bin/mysqld does not exist or is not executable.

]# /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe  --defaults-file=/etc/my.cnf &
[1] 24527
]# 2020-11-23T10:36:45.803151Z mysqld_safe Logging to '/data/wapage/hhzk/mserver/mysql5713/data/qd01-tech2-rec-build001.ps.easou.com.err'.
2020-11-23T10:36:45.809116Z mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

[1]+  Exit 1                  /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe --defaults-file=/etc/my.cnf

Note: The mysqld_safe startup script reads another startup script mysqld from the /usr/local/mysql directory by default, because my installation directory is /data/wapage/hhzk/mserver/mysql5713. So no relevant documents can be found. It can be solved in two ways.
Method 1: Create a link file in /usr/local/mysql

mkdir -p /usr/local/mysql/bin
ln -s /data/wapage/hhzk/mserver/mysql5713/bin/mysqld /usr/local/mysql/bin/mysqld

Method 2: Change all /usr/local/mysql directories in mysqld_safe to your actual installation directory

sed -i 's#/usr/local/mysql#/data/wapage/hhzk/mserver/mysql5713#g'  /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe

Guess you like

Origin blog.51cto.com/1648324/2553840