In many Linux production servers often use the database is MySQL, in the database is a lightweight database, but the use of a long time there are always some problems, the general situation is unable to read the table, at this time we will repair the table, optimize the table, reduce disk usage, to facilitate database backup.
When you enter MySQL with the root user, enter the library where the table is located
REPAIR table ' table_name ' Fix tables OPTIMIZE table ' table_name ' optimization tables
REPAIR table is used for repairing tables, while optimize table is used to reclaim unused database space, and when data rows on the table are deleted, the disk space occupied is not immediately reclaimed, and the space is reclaimed after using the Optimize Table command. And the data rows on the disk are re-queued. Optimize table is not necessarily run in many cases, as long as the batch is deleted, or a regular, such as once a week or one months to optimize the table to reduce the table data occupy disk space. Of course, in the process of repair also pay attention to the MySQL table file table_name.frm file attributes, because sometimes in the compiled version of MySQL does not have init.d in the startup script, is the MySQL under the bin directory under the Mysqld_safe tool launched, Sometimes if you do not specify the startup user or start the user is not the MySQL software used by the user startup, MySQL table file will be a problem, there will be unreadable files and so on a series of problems, so, in some cases we also use Chown to modify the MySQL table file permissions to achieve repair.
This article is from the "Technical essay" blog, please be sure to keep this source http://jim123.blog.51cto.com/4763600/1831996
MySQL Table repair and optimization