Knowledgebase

How to repair MySQL databases via SSH

Repairing MySQL databases through SSH is performed in the same way as optimizing them. The only difference is that you have to use the -r option with the command mysqlcheck. For example, to repair the tables in a single MySQL database, use the following command:

mysqlcheck -r -u (username) -p (database name)

Replace (username) with the actual username of a user that you have created for the particular database (you can also use the master username), and (database name) with the full name of the database that you want to repair. When you execute the command you'll be asked to type the password of the user. After you do it and you press Enter on your keyboard, you'll see listed the tables that are in the database. Next to each table there will be displayed OK, indicating that the table was repaired.

You can repair all databases with one command (very convenient if you have many). To do this you need to use the username and password of the MySQL master user. This user is created when you purchase a hosting account with us. You can view the user name of the master user, and set the password from the Databases section of the Pixie control panel. There's a Master Username link on the right. To repair all databases use the following SSH command:

mysqlcheck -r -u (master username) -p --all-databases

Of course, you have to replace (master username) with the real username of the master user.

For information on optimizing databases through SSH check out the article on how to optimize MySQL databases via SSH. You can also repair and optimize databases with phpMyAdmin. If you need more information on how to do that, read the tutorial on repairing and optimizing MySQL databases through phpMyAdmin.

Was this answer helpful?

 Print this Article

Also Read