How To Repair MySQL Database Files Using SSH? - TechvBlogs

How To Repair MySQL Database Files Using SSH?

In this article, we discussed the methods for repairing corrupt MySQL database files using SSH. It suggests using built-in tools like mysqlcheck and myisamchk to check, analyze, optimize, and repair MySQL databases and tables. If these methods won’t work out, we recommend using a third-party tool. Which effectively repair severely corrupted databases and offers features such as repairing MariaDB and MySQL databases, and fixing keys, relations, and tables. This tool offers a preview of the repaired database file and has a user-friendly interface. Overall, we suggest using advanced third-party repair software can help repair a database to a working state.


Guest - Author - TechvBlogs
Guest
 

10 months ago

TechvBlogs - Google News

SSH (Secure Shell Host) is not directly associated with MySQL database, but it’s generally used to establish a secure encrypted connection for remote access where the MySQL is installed. It is mostly used by developers, IT professionals, & system administrators.

On the other hand, we can say, SSH protocol offers the SSH tunneling in order to provide a secure transmission of data.

Nevertheless, you may encounter corrupted/damaged MySQL database at some point which interrupts the functionality of a website. Fortunately, there are some effective methods to repair corrupted MySQL databases.

In this optimized write-up, you will learn all the possible solutions to repair MySQL database files using SSH & restore the website to working order.

So, let’s get started…

How to Repair Corrupted MySQL Database Using SSH?

In this section, you will find both manual as well as automatic ways to repair corrupt MySQL database files.

Let’s check them out.

Method 1- Use MySQL Check Utility Repair Tool for Repairing MySQL Database

The very first method that you are suggested to use is mysqlcheck. Though mysqlcheck is an in-built utility of MySQL database management system. It is generally used to check, analyze, optimize, and repair the corrupted MySQL databases & tables along with MySQL errors.

Thus, if you want to use this utility to fix corrupt MySQL database, first create a backup of your database files so that later you can perform MySQL recovery without any trouble.

How to Back Up MySQL Files?

Follow the below steps to back up all your database files:

  • Firstly, sign in to your MySQL server & use the below command to stop the server:

service mysql stop

  • Then, you have run the below command to copy all your database files into new directory:

cp -r /var/lib/mysql /var/lib/mysql_backup

  • Restart server by running the following command:

service mysqld start

Once the backing process gets over, now proceed to repair MySQL database files using mysqlcheck command line.

How to Repair MySQL Tables using the Mysqlcheck?

Please Note: In the below steps, you can replace ‘db_name’ & ‘tbl_name’ with a name of your MySQL database & table to be fixed.

Step 1- Check for MySQL Tables Corruption

It is necessary to first identify the corrupted tables by running the below command before fixing them:

mysqlcheck –c db_name

Running the above command can help you to check for the errors in all MySQL tables of a stated database.

Instead, you can run the following command to check the corruption of specific table:

mysqlcheck –c db_name tbl_name

After completion of these steps if the report shows table error, then you must repair it. But if it returns OK, then it simply means the table isn’t corrupted.

Step 2- Repair Corrupted Tables

In order to repair the table, you have to specify a database name & table name with ‘-r’ option just shown in the below command:

mysqlcheck -r db_name tbl_name

That’s it.

If this command fails to fix the corrupted MySQL tables, databases, or errors, you can try an advanced tool- myisamchk (in-built) & Stellar Repair for MySQL.

Method 2- Advanced In-Built Tool (Myisamchk)

Another way that you can try to solve this issue is to run the first-rate tool known as myisamchk. This is another in-built tool offered by MySQL server. It helps to check & repair the corrupted or crashed tables.

Therefore, use this utility to solve the issue that you’re facing.

To use this utility, follow the beneath steps:

  • Initially, you have to stop the server of MySQL & make sure there are no active connections to the database that you wish to repair.

  • Next, locate the corrupted MySQL DB file. You can find it in MySQL data directory. If you are Linux user, you can locate it in:

/var/lib/mysql/

How To Repair MySQL Database Files Using SSH? - TechvBlogs

  • Once the database file is located, then navigate to the directory that contains the files by using the below command line:

/var/lib/mysql/mydatabase/

(Here, you can replace mydatabase with your database name)

  • After that, run the below command to repair the corrupted database:

myisamchk --recover --force --quick *.MYI

  • Now, this will instruct the myisamchk utility to execute a quick recovery of MyISAM tables in database.

  • After completion of the repairing process, restart the server of MySQL & if database is working properly.

Method 3- Advanced Third-Party Tool to Repair Corrupted MySQL Database

If the above manuals fail to work, then you are suggested to go for the versatile tool, such as Stellar Repair for MySQL. It can repair severely corrupted database using SSH without any trouble.

Moreover, it can fix MyISAM & InnoDB tables effectively. Also, this software shows a preview of the repaired database file.

Below you can find other exceptional features of this tool:

  • Repair corrupted MariaDB and MySQL databases.

  • Fixes unique keys, primary keys, relations, forms, & tables.

  • Effectively repairs MySQL stuff such as Triggers & Views in the form of a query.

  • GUI interface.

  • 100% safe & secure.

So, simply download this MySQL recovery program on your system & follow the below guide:

Step 1: Open the Stellar Repair for MySQL.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 2: Then, click Browse option in order to choose a data folder that contains the corrupt database, click OK button.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 3: Now, you can see all the MySQL files, select the file(s) you wish to repair. Next, click Repair.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 4: At this time, the program displays the progress of MySQL database fixing process.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 5: When the process gets finished, you’ll get a Repair Complete popup on your screen. Click OK.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 6: After this, the tool will display the preview of a repaired file. Then, click on File menu >> click Save.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 7: Now, select the appropriate file format and provide the required details to save the repaired file.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

Step 8: At last, “Save Complete” box will appear on your PC screen when the process gets over.

How To Repair MySQL Database Files Using SSH? - TechvBlogs

To Sum Up

Repairing the MySQL database files using manual ways doesn’t guarantee to restore its components. They might work to solve minor database problems but are unable to fix a severely corrupted MySQL database file.

Using an advanced third-party MySQL database recovery software that is Stellar Repair for MySQL can help you to repair corrupted MySQL database using SSH & restore the website to working order.

Thanks for reading…!

Comments (0)

Comment


Note: All Input Fields are required.