How to Fix MySQL Error 145?

Summary: When the MySQL error 145 occurs, you’re not able to access data in the database. In this post, we will see how to fix the error 145 in MySQL. We’ll also mention a MySQL database repair application that can help fix the error by repairing the corrupt database.

MySQL, developed by Oracle, is nowadays one of most popular database management systems (DBMS). It is written in C/C++ language and is an open-source software. You can access the data stored in the database using the SQL language. In fact, MySQL supports ANSI/ISO SQL standards.

Like any other DBMS, where software operates by reading and writing data on disk, data may get corrupt or damaged in MySQL.

The common causes that can result in data corruption or damage in MySQL include:

When the MySQL database gets corrupted, the data stored in the database becomes inaccessible and you?ll encounter the MySQL error code 145.

Let?s discuss how to fix the MySQL error code 145 and recover the data.

Methods to Fix MySQL Error 145

It is said that prevention is the best solution. Therefore, it is always recommended to make copies of the data (backup) and verify that these are working fine (test restore). In case of such errors or data corruption, you can rely on the backups to restore the data.

However, if you cannot count on a backup, then follow the given methods.

Method 1: Use MySQL Tools

MySQL provides some commands that allow you to restore the data. However, you must be careful while executing these commands as a small error can make the entire database unreadable. Always remember to make a copy of the data first.

You can use the myisamchk command, if your database uses MyISAM tables (and not the newer InnoDB tables). This command will get information about the tables.

To use this command, you need to specify an option followed by the table name (see below).

myisamchk [options] <tablename>

Many options are available but by specifying the -recover option, you can perform repair on a single table. You can also type ??r? instead of ??recover?.

This will fix any problem, except problems related to unique keys that are not unique due to a problem.

You can type:

Myisamchk ?r < tablename >

Note: Stop the MySQL service before recovering a table.

After the recovery process, you can check if the table is fine. To perform this operation, you can use the check table command as given below.

Check table <tablename> [, tablename2, etc. etc.] ... [option]

The parameter option may have the following values: FOR UPGRADE, QUICK, FAST, MEDIUM, EXTENDED, or CHANGED.

For example, you can type:

Check table <mytable> FAST QUICK;

Method 2: Use a MySQL Database Repair Software

If the recovery is not possible with the above MySQL tools, then you can use a powerful MySQL database repair software, such as Stellar Repair for MySQL, especially developed to recover data from corrupt MySQL databases. Here are its key features:

Steps to use the Stellar Repair for MySQL

On the main window, you need to enter the path of the folder which contains database files. After that, press the OK button.

A list of databases is shown. Press the Repair button.

To Conclude

Error 145 in MySQL may occur due to corruption in the database. You can use the native MySQL utilities to repair the database and fix the error. Alternatively, you can use the Stellar Repair for MySQL software, to repair the corrupt database. This application is quite powerful and extremely easy to use.

Related Post

Exit mobile version