av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

如何檢查和修復(fù)MySQL數(shù)據(jù)庫和表

當(dāng)您的網(wǎng)站因數(shù)據(jù)庫錯誤而損壞或無法訪問時,您可能需要檢查或修復(fù) MySQL 中的數(shù)據(jù)庫或表。在這種情況下,您可以使用 mysqlcheck 工具檢查并修復(fù)損壞的表或數(shù)據(jù)庫。mysqlcheck 是一個維護工具,允許您通過命令行界面檢查、修復(fù)、分析和優(yōu)化 MySQL 表。使用 mysqlcheck 的最佳功能之一是您可以在實時網(wǎng)站上執(zhí)行數(shù)據(jù)庫維護,而無需停止 MySQL 服務(wù)。

陽明網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,陽明網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為陽明上千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的陽明做網(wǎng)站的公司定做!

在這篇文章中,我們將解釋如何檢查/修復(fù) MySQL 數(shù)據(jù)庫和表。

先決條件

  • 運行 Linux 的服務(wù)器
  • 在您的服務(wù)器上配置的 root 密碼

mysqlcheck的基本語法

mysqlcheck 命令行工具的基本語法如下所示:

mysqlcheck [OPTION] DATABASENAME TABLENAME -u root -p

下面顯示了可以與 mysqlcheck 一起使用的每個選項的簡要說明:

  • -c - 檢查表是否有錯誤
  • -C - 檢查上周之后更改的表。
  • -a - 分析表。
  • -A - 檢查所有數(shù)據(jù)庫。
  • -g - 檢查表以獲取與版本相關(guān)的更改。
  • -B , –databases – 指定多個數(shù)據(jù)庫。
  • -F - 檢查未正確關(guān)閉的表。
  • –fix-db-names – 修復(fù)數(shù)據(jù)庫名稱。
  • –fix-table-names – 修復(fù)表名。
  • -e - 執(zhí)行擴展檢查。
  • -r - 修復(fù)損壞的表。

在 MySQL 中檢查表

有時,您可能需要檢查特定數(shù)據(jù)庫中的特定表。在這種情況下,您可以使用以下語法:

mysqlcheck -c db-name table-name -u root -p

例如,要檢查 class 數(shù)據(jù)庫中的 students 表,請運行以下命令:

mysqlcheck -c class students -u root -p

您將獲得以下輸出:

class.students                                      OK

檢查 MySQL 中的所有表

如果要檢查特定數(shù)據(jù)庫中的所有表,請使用以下語法:

mysqlcheck -c db-name -u root -p

例如,要檢查 class 數(shù)據(jù)庫中的所有表,請運行以下命令:

mysqlcheck -c class -u root -p

您應(yīng)該得到以下輸出:

Enter password:  
class.teacher OK
class.students OK
class.peon OK

檢查和優(yōu)化所有表和所有 MySQL 數(shù)據(jù)庫

您可以使用以下命令檢查所有表和所有數(shù)據(jù)庫:

mysqlcheck -c  -u root -p --all-databases

輸出:

Enter password:  
class.teacher OK
class.students OK
class.peon OK
guest.MyGuests OK
movies.hotstar OK
mysql.columns_priv OK
mysql.component OK
mysql.db OK
mysql.default_roles OK
mysql.engine_cost OK
mysql.func OK
mysql.general_log OK
mysql.global_grants OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.password_history OK
mysql.plugin OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.role_edges OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK

您還可以使用以下命令優(yōu)化所有表和所有數(shù)據(jù)庫:

mysqlcheck -o root -p --all-databases

輸出:

Enter password:  
class.teacher
note : Table does not support optimize, doing recreate + analyze instead
status : OK
class.students
note : Table does not support optimize, doing recreate + analyze instead
status : OK
class.peon
note : Table does not support optimize, doing recreate + analyze instead
status : OK
guest.MyGuests
note : Table does not support optimize, doing recreate + analyze instead
status : OK
movies.hotstar
note : Table does not support optimize, doing recreate + analyze instead
status : OK
mysql.columns_priv

在上面的輸出中,您應(yīng)該看到“ Table does not support optimize ”,這意味著 InnoDB 表不支持此選項。

修復(fù) MySQL 數(shù)據(jù)庫

要修復(fù) class 數(shù)據(jù)庫中的 teacher 表,請運行以下命令:

mysqlcheck -r class teacher -u root -p

輸出:                         

mysqlcheck -r class teacher -u root -p
Enter password:
class.teacher OK

要修復(fù) class 和 movies 數(shù)據(jù)庫中的所有表,請運行以下命令:

mysqlcheck -r --databases class movies -u root -p

輸出:

Enter password:  
class.teacher OK
class.students OK
class.peon OK
movies.hotstar OK

如果要檢查和修復(fù)所有數(shù)據(jù)庫中的所有表,請運行以下命令:

mysqlcheck --auto-repair --all-databases -u root -p

輸出:

Enter password:  
class.teacher OK
class.students OK
class.peon OK
guest.MyGuests OK
movies.hotstar OK
mysql.columns_priv OK
mysql.component OK
mysql.db OK
mysql.default_roles OK
mysql.engine_cost OK
mysql.func OK
mysql.general_log OK
mysql.global_grants OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.password_history OK
mysql.plugin OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.role_edges OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK

注意:默認(rèn)情況下,InnoDB 存儲引擎不支持修復(fù)。在這種情況下,您需要將 MySQL 存儲引擎從 InnoDB 更改為 MyISAM。

結(jié)論

在這篇文章中,我們解釋了如何使用 mysqlcheck 命令行工具檢查和修復(fù) MySQL 中的表。


文章標(biāo)題:如何檢查和修復(fù)MySQL數(shù)據(jù)庫和表
網(wǎng)站網(wǎng)址:http://uogjgqi.cn/article/djspohc.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流