Repair MySQL Database through Linux Terminal(SSH)
- Login to your Linux VPSÂ using Secure Shell (SSH) and connect to MySQL from the command line.
mysql -uUsername -p // Replace Username with your username.
- Enter MySQL user password and hit Enter. You will see mysql prompt appearing. Now, in order to display all databases, type following command at mysql prompt.
show databases;
- mysqlcheck enables you to check databases without stopping the entire MySQL service. -r argument is used to repair the corrupted tables. mysqlcheck utility efficiently works on both MyISAM and InnoDB database engines. Enter following command to repair MySQL database.
mysqlcheck -r [database] // Replace database name with your database name.
Repair MySQL Database through Windows Command Line
- Login to your Windows VPS using Remote Desktop.
- Go to Start and locate Command Prompt. Right click Command Prompt and select Run as Administrator option.
- At windows command prompt navigate to MySQL bin directory as follows.
cd C:\Program Files\MySQL\MySQL Server 5.5\bin // Replace your MySQL bin directory path here.
- Run the following command to start the MySQL prompt.
mysql -u root -p
- Enter MySQL root password when you are being asked.
- You will see mysql prompt appearing. Now, to display all databases, type following command at mysql prompt:
show databases;
- Enter the following command to repair MySQL database.
mysqlcheck -r [database] // Replace database name with your database name.