Check and Optimize MySQL Database Automatically with Crontab/Cron Prüfen und Optimieren von MySQL-Datenbank automatisch mit crontab / Cron
MySQL is a very popular free yet powerful database system. MySQL ist eine sehr beliebte kostenlose noch leistungsfähige Datenbank-System. 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. Aber auch in großen Datenbanken, die Tabellen kann es fragmentiert ist und die Gemeinkosten durch eine kontinuierliche Aktualisierung, oder zu löschen, und legen Sie am gespeicherten Daten in der Datenbank. Beside, it's also possibility that the databases may get corrupted. Außer, es ist auch möglich, dass die Datenbanken beschädigt. Thus, performing health check on database and optimize MySQL server regularly is an important task. So, Gesundheits-Check über die Durchführung und Optimierung von MySQL-Datenbank-Server regelmäßig ist eine wichtige Aufgabe.
It's a 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. Es ist ein bisschen problematisch, wenn die Datenbank-Administratoren müssen sich hier anmelden, auf den Server oder den Start der phpMyAdmin zur Optimierung der Datenbanken einzeln oder Tabelle Tabelle manuell. Sometimes DB admin may simply forgets to do the job or set the frequency of optimization to lesser times. Manchmal DB Admin einfach vergisst, den Job zu erledigen oder die Häufigkeit der Optimierung zu mal weniger. It's recommended that every tables in MySQL databases are checked at least once a day on a busy server. Es wird empfohlen, dass alle Tabellen in MySQL-Datenbanken sind mindestens einmal pro Tag auf einem stark ausgelasteten Server.
It's possible to automate the optimization of MySQL process by using crontab function in Linux/Unix/CentOS/FreeBSD. Es ist möglich, für die automatisierte Optimierung von MySQL-Prozess mit crontab-Funktion in Linux / Unix / CentOS / FreeBSD. The cron job to check and optimize MySQL databases can be created by using mysqlcheck client utility comes MySQL installation. Die cron-Job zu überprüfen und optimieren MySQL-Datenbanken erstellt werden können, indem Sie mysqlcheck-Client-Dienstprogramm kommt MySQL-Installation. mysqlcheck client can checks, repairs, optimizes, and analyzes tables in MySQL database. mysqlcheck-Client kann prüft, repariert, optimiert und analysiert Tabellen in MySQL-Datenbank.
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. So erstellen Sie einen neuen Cron-Job, Login auf dem Server als root oder einem anderen Benutzer, und bearbeiten Sie dann die crontab-Datei (in den meisten Betriebssystemen, crontab-e crontab-Datei wird in der Standard-Text-Editor), um in der folgenden Zeile des Textes . For users using cPanel, click on “Cron job” where you can set up crontab at daily, hourly and other interval. Für Anwender, die cPanel, klicken Sie auf "cron-Job", wo können Sie crontab auf Tages-, Stunden-und anderen Intervall. Experience webmasters can also set up a crontab file in rc.hourly or rc.daily or other cron directory. Erleben Sie Webmaster können auch eine crontab-Datei in rc.hourly oder rc.daily oder andere Cron-Verzeichnis. 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. Beachten Sie, dass, wenn Sie sich anmelden oder MySQL als normaler Benutzer keine Zugriffsrechte auf alle Datenbanken, ist es nicht möglich, alle Datenbanken zu optimieren, es sei denn, Benutzer-ID und das Passwort für root ist wie im Beispiel unten.
0 1 * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null 0 1 * * * mysqlcheck-AAO-auto-Reparatur-u root-p [passwort]> / dev / null
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. Die oben genannten Erklärung hat die Syntax ähnlich wie bei "mysqlcheck [options]-all-databases", in dem all-databases-Parameter ist die Standard-Aktion ist keine Datenbanken ist damit kann weggelassen werden. The command will run mysqlcheck client to automatically analyze and optimize all databases at 1 am everyday. Der Befehl wird mysqlcheck-Client automatisch zu analysieren und optimieren alle Datenbanken auf 1 Uhr täglich. Note that there is not space between -p and your password for root. Beachten Sie, dass es keine Leerzeichen zwischen-p und Ihr Passwort für root. You can change the running time to your preference, and also change the options for mysqlcheck command. Sie können die Laufzeit nach Ihren Wünschen, und auch die Optionen für mysqlcheck Befehl. If you just want to check and optimize certain databases or certain tables without the database, use the following syntax: Wenn Sie nur wollen, zu überprüfen und optimieren bestimmte Datenbanken oder bestimmte Tabellen ohne die Datenbank, verwenden Sie die folgende Syntax:
mysqlcheck [options] db_name [tables] mysqlcheck [options] db_name [Tabellen]
mysqlcheck [options] –databases DB1 [DB2 DB3...] mysqlcheck [options]-Datenbanken 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. Sie können remove-Auto-Reparatur-Schalter aus den oben genannten Befehl, wie eine Tabelle Reparatur könnte zu Datenverlust führen, unter bestimmten Umständen den Betrieb aufgrund der Ursachen sind aber nicht beschränkt auf Dateisystem-Fehler. For those who has changed the character set and collation of MySQL databases may also need to use –default-character-set option. Für diejenigen, die sich geändert hat den Zeichensatz und Sortierung von MySQL-Datenbanken müssen unter Umständen auch zu nutzen-default-character-set-Option. More information on all available switches and options available can be found Mehr Informationen über alle verfügbaren Schalter und die verfügbaren Optionen finden Sie here hier . .
IMPORTANT : The page is machine translated and provided "as is" without warranty. WICHTIG: Die Seite ist Maschine übersetzt und "as is" ohne Garantie. Machine translation may be difficult to understand. Maschinelle Übersetzung kann schwierig zu verstehen. Please refer to Bitte beachten Sie original English article Original Englisch Artikel whenever possible. wann immer dies möglich ist.
Related Articles In Verbindung stehende Artikel
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL-Datenbank-Performance Tuning Best Practices Video-Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Aktivieren Sie Protokollierung von Abfragen Langsam (Slow Query Log) in MySQL-Datenbank
- How to Find and Replace Text in MySQL Database using SQL Wie Sie auf "Suchen und Ersetzen von Text in MySQL-Datenbank mit SQL
- Change and Reset MySQL root Password Change and Reset MySQL root-Passwort
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 Installation von Web Server in FreeBSD 6.0 mit Apache 2.2, MySQL 5.0 und PHP 5 - Teil 3
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Entfernen oder Trim First oder letzten Zeichen in MySQL-Datenbank mit SQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Wie Backup-und Restore (Export und Import) Datenbanken MySQL Tutorial
- Reset the Root Password of MySQL Server Setzen Sie den Root-Passwort des MySQL-Server
- Using phpMyAdmin for Effective MySQL Management in Windows XP Mit phpMyAdmin für MySQL Effektive Management in Windows XP
- Install phpBB 2 in Windows XP running on Apache 2, PHP 5 and MySQL 4 Install phpBB 2 in Windows XP läuft auf Apache 2, PHP 5 und MySQL 4










































April 2nd, 2009 09:41 2 Apr 2009 09:41
I'ma newby on managing MySQL. Ich bin ein Newby über den Umgang mit MySQL.
I want to ask you, how to to make sure if the Cron is working? Ich möchte Sie fragen, wie man, um sicherzustellen, dass, wenn der Cron ist?
Thanks Danke
November 16th, 2008 12:48 16. Nov. 2008 12:48
along the lines of what Zubin is suggesting you can use the –silent(-s) switch as well, so you only get output if there is an error, something like entlang der Linien von dem, was Zubin schlägt können Sie den-silent (-s)-Schalter als auch, so dass Sie nur dann ausgegeben, wenn es ein Fehler, so etwas wie
MAILTO=email@domain.com MAILTO = email@domain.com
0 1 * * * mysqlcheck -Aaos -uroot -ppassword 0 1 * * * mysqlcheck-AAOS-uroot-ppassword
this way you will only get an email if there is an error diese Weise werden Sie nur eine E-Mail erhalten, wenn es ein Fehler
September 20th, 2008 18:34 Der 20. September 2008 18:34
Sure mysql does need frequent tunning, and also I have seen a lot of the servers running in the default configuration. Sie sicher, MySQL braucht häufig tunning, und auch ich habe viel von den Servern, die in der Standard-Konfiguration. which happens to be a very modest one. was sich als sehr bescheiden. If you have access to the mysql configuration file, there are some values that can make your server breathe more often. Wenn Sie Zugang zu den MySQL-Konfigurations-Datei, gibt es einige Werte, die sich um Ihren Server atmen häufiger. And make your visitors more happy. Und machen Sie Ihren Besuchern mehr glücklich.
May 6th, 2008 19:15 6. Mai 2008 19:15
I did not know that it was nesessary to perform a regular check for mysql. Ich wusste nicht, dass es nesessary, um eine regelmäßige Überprüfung auf MySQL.
January 16th, 2008 06:40 16. Januar 2008 06:40
Note that -–auto-repair should have two dashes Beachten Sie, dass - Auto-Reparatur müssen zwei Bindestriche
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). Auch Sie könnten zu verlassen "> / dev / null" für die ersten paar Durchläufe, um zu sehen, die Ergebnisse des Befehls (wenn Sie MAILTO = me@mydomain.com an der Spitze der crontab, die Ergebnisse werden gesendet gibt).