Check and Optimize MySQL Database Automatically with Crontab/Cron檢查和優化MySQL數據庫自動Crontab /玉米

MySQL is a very popular free yet powerful database system. MySQL是一個非常受歡迎的免費而強大的數據庫系統。 But even in great databases, the tables may get fragmented with overhead due to continuous update, or delete and insert operation on data stored in database.但是,即使是在偉大的數據庫,表可能會分散,間接由於不斷更新,或刪除和插入操作的數據存儲在數據庫中。 Beside, it’s also possibility that the databases may get corrupted.旁邊,這也是可能的數據庫可能會損壞。 Thus, performing health check on database and optimize MySQL server regularly is an important task.因此,從事健康檢查的數據庫和優化MySQL服務器經常是一項重要任務。

It’sa bit troublesome if the database administrators have to login to the server or launching the phpMyAdmin to optimize the databases one by one or table by table manually.這是一個有點麻煩,如果數據庫管理員已經登錄到服務器或發起phpMyAdmin優化一個數據庫由一個或表的表手動。 Sometimes DB admin may simply forgets to do the job or set the frequency of optimization to lesser times.有時,數據庫管理員可能只是忘記做的工作或設置的頻率較低優化倍。 It’s recommended that every tables in MySQL databases are checked at least once a day on a busy server.它的每一個建議,表在MySQL數據庫進行檢查至少一次,每天在繁忙的服務器上。

It’s possible to automate the optimization of MySQL process by using crontab function in Linux/Unix/CentOS/FreeBSD.這有可能自動優化過程中的MySQL使用crontab功能在Linux / UNIX / CentOS / FreeBSD的。 The cron job to check and optimize MySQL databases can be created by using mysqlcheck client utility comes MySQL installation.該計劃作業,檢查和優化MySQL的數據庫,可以創建使用mysqlcheck客戶端工具來自MySQL的安裝。 mysqlcheck client can checks, repairs, optimizes, and analyzes tables in MySQL database. mysqlcheck客戶可以檢查,維修,優化,分析表中MySQL數據庫。

To create a new cron job, login to the server as root or any other user, and then edit the crontab file (in most operating system, crontab -e will open crontab file in default text editor) to add in the following line of text.要創建新的計劃作業,登錄到服務器作為根或任何其他用戶,然後編輯crontab文件(在大多數操作系統, crontab娥將打開crontab文件中預設的文字編輯器)中添加下面一行文字。 For users using cPanel, click on “Cron job” where you can set up crontab at daily, hourly and other interval.對於用戶使用的cPanel ,點擊“玉米工作”您可以在這裡設立了crontab在每天,每小時和其他間隔。 Experience webmasters can also set up a crontab file in rc.hourly or rc.daily or other cron directory.網站管理員的經驗也可以設立一個crontab文件中rc.hourly或rc.daily或其他玉米目錄。 Note that if you login as a MySQL or normal user with no access privileges to all database, it’s not possible to optimize all databases, unless user ID and password for root is specified as in example below.請注意,如果您登錄作為一個MySQL或普通用戶沒有訪問權限的所有數據庫,它是不可能的優化所有數據庫,除非用戶ID和密碼的根被指定為在以下範例。

0 1 * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null 0 1 * * * mysqlcheck ,氧化鋁,汽車修理聚氯乙烯根一p [密碼] “的/ dev /無效

The above statement has the syntax similar to “mysqlcheck [options] –all-databases”, where –all-databases parameter is the default action is no databases is specified thus can be omitted.上述聲明的語法類似“ mysqlcheck [選項] ,所有數據庫” ,其中,所有的數據庫參數是默認的行動是沒有指定數據庫因此可以省略。 The command will run mysqlcheck client to automatically analyze and optimize all databases at 1 am everyday.該命令將運行mysqlcheck客戶端會自動分析和優化所有數據庫在每天凌晨1點。 Note that there is not space between -p and your password for root.請注意,不存在空間之間的p和密碼的根源。 You can change the running time to your preference, and also change the options for mysqlcheck command.您可以更改運行時間為您選擇,同時也改變選擇mysqlcheck命令。 If you just want to check and optimize certain databases or certain tables without the database, use the following syntax:如果你只是要檢查和優化某些數據庫或某些表的數據庫,請使用以下語法:

mysqlcheck [options] db_name [tables] mysqlcheck [選項] db_name [表]
mysqlcheck [options] –databases DB1 [DB2 DB3...] mysqlcheck [選項]數據庫DB1 [的DB2 DB3 ... ]

You may want to remove –auto-repair switch from the above command, as a table repair operation might cause data loss under some circumstances the operation due to causes include but are not limited to filesystem errors.您可能想要移除,汽車修理開關從上述命令,作為一個表修復操作可能導致數據丟失,在某些情況下的運作由於原因包括但不限於文件的錯誤。 For those who has changed the character set and collation of MySQL databases may also need to use –default-character-set option.對於那些誰改變了字符集和整理的MySQL數據庫,可能還需要使用默認字符集的選擇。 More information on all available switches and options available can be found更多的信息所有可用的交換機和可供選擇可以找到 here在這裡 .

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要說明:這是一台機器翻譯網頁這是“原樣”提供,無保修。 Machine translation may be difficult to understand.機器翻譯可能很難理解。 Please refer to請參閱 original English article英文原文的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at共享和貢獻或獲得技術支持和幫助 My Digital Life Forums 我的數字生活論壇 .



3 Responses to “Check and Optimize MySQL Database Automatically with Crontab/Cron”三響應“檢查和優化MySQL數據庫自動與Crontab /玉米”

  1. Zubin祖賓
    January 16th, 2008 06:40 08年1月16日06:40
    1

    Note that -–auto-repair should have two dashes請注意, -汽車修理應該有兩個破折號

    Also, you might want to leave “> /dev/null” out for the first few runs, to see the results of the command (if you put MAILTO=me@mydomain.com at the top of the crontab, the results will get sent there).此外,您可能要離開“ ”的/ dev /空“出的前幾個運行時,看到的結果,命令(如果你把地址= me@mydomain.com上方的crontab ,其結果將得到派往那裡) 。

  2. Mike -邁克-
    May 6th, 2008 19:15 2008年五月六日19:15
    2

    I did not know that it was nesessary to perform a regular check for mysql.我不知道這是nesessary進行定期檢查的數據庫。

  3. php-trivandrum主機特里凡得瑯
    September 20th, 2008 18:34二〇 〇八年9月20日18:34
    3

    Sure mysql does need frequent tunning, and also I have seen a lot of the servers running in the default configuration.當然數據庫確實需要經常整,還我看到了很多服務器運行中的默認配置。 which happens to be a very modest one.這恰好是一個非常溫和的。 If you have access to the mysql configuration file, there are some values that can make your server breathe more often.如果您有機會獲得MySQL的配置文件,有一些價值,可以讓你的服務器呼吸更加頻繁。 And make your visitors more happy.使您的訪問者更幸福。

Leave a Reply留下一個回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用這些標籤: href="" title="">的<a <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> “刪除日期時間= “ ” “的<em> <i> <q cite=""> <strike>的<strong>

Subscribe without commenting訂閱沒有評論


Custom Search

New Articles新文章

Incoming Search Terms for the Article收到的搜索字詞的文章

mysql check database 檢查MySQL的數據庫 - - optimize mysql database 優化MySQL數據庫 - - check mysql database 檢查MySQL數據庫 - - mysql database check MySQL數據庫檢查 - - check database mysql 檢查數據庫MySQL - - mysql check db MySQL的檢查分貝 - - mysqlcheck optimize mysqlcheck優化 - - optimize database 優化數據庫 - - mysql optimize database MySQL的優化數據庫 - - mysql optimize all databases MySQL的優化所有數據庫 - - optimize mysql table 優化數據庫表 - - how to optimize mysql database 如何優化MySQL數據庫 - - mysql optimize command 優化MySQL的命令 - - mysql optimize MySQL的優化 - - mysql auto repair MySQL的汽車修理 - - mysql check 數據庫檢查 - - mysql check tables MySQL的檢查表 - - optimize mysql db 優化MySQL的數據庫 - - mysqlcheck cron mysqlcheck玉米 - - mysql cron MySQL的玉米 - - crontab mysql crontab數據庫 - - how to check mysql database 如何檢查MySQL數據庫 - - mysql check table MySQL的檢查表 - - optimize mysql 優化數據庫 - - optimize database mysql 優化數據庫MySQL - - cron mysql 玉米數據庫 - - check mysql db 檢查數據庫分貝 - - mysql optimize repair MySQL的優化修復 - - wordpress mysql optimize WordPress的數據庫優化 - - mysql db check MySQL的數據庫檢查 - - check mysql table 檢查數據庫表 - - cron checker 冠群檢查 - - mysql optimize cron MySQL的優化,克朗 - - Optimize MySQL Cron 優化MySQL的玉米 - - MySQL optimize db MySQL的優化分貝 - - mysql health check 數據庫健康檢查 - - optimize mysql wordpress WordPress的優化數據庫 - - optimize mysql tables 優化數據庫表 - - mysql repair database 數據庫修復數據庫 - - optimizing mysql database 優化MySQL數據庫 - - mysql table optimize 數據庫表優化 - - check table mysql 檢查表數據庫 - - check mysql 檢查數據庫 - - mysqlcheck database mysqlcheck數據庫 - - mysql crontab MySQL的crontab - - optimize mysql server 優化MySQL服務器 - - repair mysql db 修復數據庫分貝 - - mysql check databases 檢查MySQL的數據庫 - - mysql autorepair 數據庫autorepair - - cron mysqlcheck 玉米mysqlcheck - -