How to solve the “table crashed” error on MySQL / MariaDB?

0
80

If there is one characteristic that defines database managers in Linux, it is robustness. This concept is associated with the reliability of the program. As a consequence, we always have our data available at any time, either through a direct consultation or through an application. However, there are errors that may appear. In this opportunity, I will help you to solve a MySQL or MariaDB error.

Solving the table crashed error on MySQL / MariaDB

When I was going to review the tables at the request of the people who use the administrative system in my work, I came across the following:

“Table is marked as crashed and should be repair”

I had run into this mistake before, so I did not freak out because I knew the solution, but many do not know it. So that’s the reason to make this post.

The origin of this error is different, most likely it was caused by an unexpected restart or shutdown of the MySQL or MariaDB service. That is to say, although it is not a very recurrent error it can cause a headache. It happens in home servers or in local instances where there is an electrical problem. Or where the service stops unexpectedly.

To solve the error, we must use the mysqlcheck command. This command is very useful because it allows maintenance operations, optimization and repair of database and tables. And in this case, it is just what we need.

So, tun this command:

:~$ sudo mysqlcheck -u [user] -p --all-databases --auto-repair

The command, which requires superuser privileges, verifies all databases. If it finds a corrupt one, then it will repair it automatically.

However, it is also possible to specify a single database. It is useful if we already know where the damaged table is.

:~$ sudo mysqlcheck -u [user] -p --databases [database] --auto-repair

And with this, that solves the matter. Finally, for this command to work, it is necessary that the MySQL or MariaDB instance is running.

Conclusion

Sometimes some errors can be easily solved but when you do not know the solution there are difficult moments. And if the problem is with the data, even more so. So in this post, we have taught you how to solve a MySQL or MariaDB.

Please share this post with your friends.

LEAVE A REPLY

Please enter your comment!
Please enter your name here