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.创建一个新的作业,登录到服务器,以root的身份或任何其他用户,然后编辑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或其他的CRON目录。 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 - aao -自动修复中美根- P的[密码] > /开发/空

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 我的数字生活论坛 .



2 Responses to “Check and Optimize MySQL Database Automatically with Crontab/Cron” 2反应“检查和优化MySQL数据库自动与crontab /玉米”

  1. Zubin祖宾
    January 16th, 2008 06:40 2008年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).此外,您可能会想要离开“ > /开发/无效” ,首次阐明了几个运行时,看到的结果,命令(如果你把的mailto = me@mydomain.com在上方的crontab ,结果将得到派有工作) 。

  2. Mike -麦克-
    May 6th, 2008 19:15 2008年5月6日19时15分
    2

    I did not know that it was nesessary to perform a regular check for mysql.我不知道,这是nesessary执行定期检查,同时为MySQL开发。

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> 您可以使用这些标签:的<a href="" title=""> <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的检查数据库 - - check mysql database 检查MySQL数据库 - - optimize mysql database 优化MySQL数据库 - - check database mysql 检查数据库的MySQL - - mysql check db MySQL的检查分贝 - - mysql database check MySQL数据库检查 - - optimize database 优化数据库 - - mysqlcheck optimize mysqlcheck优化 - - mysql optimize all databases MySQL的优化所有数据库 - - mysql optimize database MySQL的优化数据库 - - how to optimize mysql database 如何优化MySQL数据库 - - mysql optimize command MySQL的优化命令 - - mysql check tables MySQL的检查表 - - mysql auto repair MySQL的汽车修理 - - cron mysql 玉米的MySQL - - mysql check table MySQL的检查表 - - mysql optimize MySQL的优化 - - mysql cron MySQL中的CRON - - cron checker 检查的CRON - - mysql optimize repair MySQL的优化修复 - - optimize mysql db 优化MySQL的分贝 - - mysql db check MySQL的分贝检查 - - optimize mysql table 优化MySQL的表 - - check mysql db 检查MySQL的分贝 - - mysql check MySQL的检查 - - check mysql table 检查MySQL的表 - - crontab mysql crontab的MySQL - - optimize mysql wordpress 优化MySQL中的WordPress - - optimize mysql tables 优化MySQL的表 - - mysql repair database MySQL的修复数据库 - - mysql optimize cron MySQL的优化的CRON - - optimize database mysql 优化数据库的MySQL - - check table mysql 检查表的MySQL - - repair mysql db 修复MySQL的分贝 - - optimize mysql MySQL的优化 - - mysql check databases MySQL的检查数据库 - - Optimize MySQL Cron 优化MySQL中的CRON - - MySQL optimize db MySQL的优化分贝 - - mysql table optimize MySQL的表优化 - - how to check mysql database 如何检查MySQL数据库 - - optimize command mysql 优化MySQL的命令 - - otimizar mysql otimizar的MySQL - - optimize mysql server 优化MySQL服务器 - - auto-repair mysql 自动修复的MySQL - - cronjob optimize tables cronjob优化表 - - check database 检查数据库 - - optimize a database 优化数据库 - - wordpress mysql optimize 在WordPress MySQL的优化 - - mysql health check MySQL的健康检查 - - optimizing mysql database 优化MySQL数据库 - -