MySQL: 48 --- Database Maintenance (analyze table, check table), diagnostic startup problems, the log file

First, the database maintenance

  • MySQL provides a series of statements, it can (should) be used to ensure proper and normal operation of the database

analyze table

  • This statement is used to check whether the correct key table

check table

  • This statement is used for many of the issues on the table checks
  • The index to check on MyISAM tables
  • This statement supports a range of ways for MyISAM tables
  • changed since the last inspection checks depend altered table
  • extended to perform the most thorough check, fast check not only normally closed table
  • medium Check all the deleted links and key test
  • quick quick scan carried out only

  • If a MyISAM table access produce incorrect and inconsistent results, you may need repair table to fix the corresponding table. This statement should be used infrequently, if required frequent use may have bigger problems to solve
  • If a large amount of data deleted from a table, to optimize table should be used to recover the space used to optimize performance list

Second, view the log file

  • MySQL to maintain a series of log file administrator dependent. The main log files are the following:
    • Error Log: It contains startup and shutdown issues and key details of the error. This log is usually called hostname.err, located in the data directory. This name is available --log-error log command-line options to change
    • Query Log: It records all activities of MySQL, is very useful when diagnosing problems. This log file can quickly become very large, so it should not be long-term use. This log is usually called hostname.log, located in the data directory. This name can be used to change the command-line option --log
    • Binary Log: It records the updated data (or possibly updated data) of all statements. This log usually named hostname-bin, located within the data directory. This name can be used --log-bin command-line options to change. Note that this log file is added to MySQL 5, the previous version of MySQL update log is used
    • Slow query log: This log records to perform any query slow. This log in determining the need to optimize the database where useful. This log usually named hostname-slow.log, located in the data directory. This option can name with --log-slow-queries command line change
  • When using logs, available flush logs statement to refresh and restart all the log files
Released 1342 original articles · won praise 876 · Views 230,000 +

Guess you like

Origin blog.csdn.net/qq_41453285/article/details/104056515