Check and Optimize MySQL Database Automatically with Crontab/Cron Pārbaudiet un Optimizējiet MySQL Database Automātiski ar Crontab / Cron
MySQL is a very popular free yet powerful database system. MySQL ir ļoti populārs brīvā vēl jaudīgu datu bāzes sistēmu. 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. Bet pat ļoti datubāzēm, tabulās var kļūt sadrumstalots ar kontaktstrāvas dēļ nepārtraukti atjaunināt vai dzēst un ievietojiet darbībai uz datiem, kas uzglabāti datubāzē. Beside, it's also possibility that the databases may get corrupted. Blakus, ir arī iespēja, ka datubāzes var kļūt bojāti. Thus, performing health check on database and optimize MySQL server regularly is an important task. Tādējādi, veicot veselības pārbaudi par datu bāzi un pilnveidot MySQL servera regulāri ir svarīgs uzdevums.
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. Tas ir mazliet apgrūtinoša, ja datu bāzes administrators ir login ar serveri vai palaišanai ar phpMyAdmin, lai optimizētu datu bāzes, pa vienam vai galda ar tabulu manuāli. Sometimes DB admin may simply forgets to do the job or set the frequency of optimization to lesser times. Dažreiz BP admin var vienkārši aizmirst, lai veiktu darbu vai noteikt biežumu optimizācijas mazākā reizes. It's recommended that every tables in MySQL databases are checked at least once a day on a busy server. Tas ir ieteicams, ka katru tabulu MySQL datubāzes ir pārbaudīti vismaz vienu reizi dienā, ir aizņemta serveri.
It's possible to automate the optimization of MySQL process by using crontab function in Linux/Unix/CentOS/FreeBSD. Tas ir iespējams automatizēt optimizācijai MySQL process, izmantojot crontab funkciju Linux / Unix / CentOS / FreeBSD. The cron job to check and optimize MySQL databases can be created by using mysqlcheck client utility comes MySQL installation. Par Cron darbs, lai pārbaudītu un optimizēt MySQL datu bāzes var izveidot, izmantojot mysqlcheck klients lietderība nāk MySQL uzstādīšana. mysqlcheck client can checks, repairs, optimizes, and analyzes tables in MySQL database. mysqlcheck klients var pārbaudēm, remonts, pilnveido, un analizē tabulas MySQL datu bāzi.
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. Lai izveidotu jaunu Cron darbu, piesakieties uz servera, kā saknes vai jebkurš cits lietotājs, un pēc tam rediģēt crontab fails (vairumā operētājsistēmu, crontab-e atvērs crontab failu noklusējuma teksta redaktoru) ar ko pievieno šādos rindiņa . For users using cPanel, click on “Cron job” where you can set up crontab at daily, hourly and other interval. Lietotājiem, izmantojot cPanel, noklikšķiniet uz "Cron darbu", kur var izveidot crontab dienas, stundas un citas intervālu. Experience webmasters can also set up a crontab file in rc.hourly or rc.daily or other cron directory. Pieredze Tīmekļa pārziņi var izveidot crontab failu rc.hourly vai rc.daily vai citu Cron direktorijā. 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. Ievērojiet, ka, ja jūs piesakieties kā MySQL vai parastu lietotāju ar nekādas piekļuves privilēģijas uz visām datu bāzē, tas nav iespējams, lai optimizētu visu datu bāzes, ja vien lietotāja ID un paroli sakne tiek precizēta kā piemērā turpmāk.
0 1 * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null 0 1 * * * mysqlcheck-Aao-auto-remonts-u root-p [parole]> / 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. Iepriekš minētais paziņojums ir sintakse līdzīga "mysqlcheck [iespējas]-all-datubāzēm", kur-all-datubāzēs parametrs ir noklusējuma darbība nav datubāzēs ir norādīts tādējādi to var izlaist. The command will run mysqlcheck client to automatically analyze and optimize all databases at 1 am everyday. Komandiera darbosies mysqlcheck klients automātiski analizējam un optimizēt visu datubāzēs 1 am ikdienas. Note that there is not space between -p and your password for root. Atcerieties, ka tur nav atstarpe starp-p un jūsu paroli root. You can change the running time to your preference, and also change the options for mysqlcheck command. Jūs varat mainīt darba laika, lai savu izvēli, kā arī mainīt iespējas mysqlcheck komandu. If you just want to check and optimize certain databases or certain tables without the database, use the following syntax: Ja jūs vienkārši vēlaties pārbaudīt un optimizēt dažu datubāzu, vai dažas tabulas bez datu bāzē, izmanto šādu sintaksi:
mysqlcheck [options] db_name [tables] mysqlcheck [iespējas] db_name [tabulas]
mysqlcheck [options] –databases DB1 [DB2 DB3...] mysqlcheck [iespējas]-datubāzēs 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. Varat izņemt-auto-remonts pāriet no iepriekš komanda, kā galda remonta darbība var radīt datu zudumiem, kas atsevišķos gadījumos darbības dēļ ietver, bet neaprobežojas ar filesystem kļūdas. For those who has changed the character set and collation of MySQL databases may also need to use –default-character-set option. Tiem, kas ir mainījies rakstzīmju kopas un apkopošana MySQL datubāzēm var būt nepieciešama, lai izmantotu-default rakstzīmju komplekta izvēle. More information on all available switches and options available can be found Plašāka informācija par visiem pieejamajiem slēdži un iespējām var atrast here šeit . .
IMPORTANT : The page is machine translated and provided "as is" without warranty. SVARĪGI: Šī lapa ir mašīna tulkoto un ar nosacījumu ", kas ir" bez garantijas. Machine translation may be difficult to understand. Machine translation var būt grūti saprast. Please refer to Lūdzu, skatiet original English article oriģināls angļu rakstu whenever possible. kad vien iespējams.
Related Articles Saistītie raksti
- How to Disable Linux and Unix Cron Jobs (Crontab) Email Sending Kā Atslēgt Linux un Unix Cron darbavietām (Crontab) E-pasts sūtīšana
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL Database Performance Tuning Best Practices Video Tutorial
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Enable iegrāmatošana Lēna vaicājumu (Lēna Query Log) in MySQL Database
- How to Find and Replace Text in MySQL Database using SQL Kā, lai atrastu un aizstātu tekstu MySQL datu bāzē, izmantojot SQL
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Instalēšana Web serveri FreeBSD 6,0 ar Apache 2.2, MySQL 5.0 un PHP 5 - 3.daļa
- Change and Reset MySQL root Password Pārmaiņām un Reset MySQL root parole
- Remove or Trim First or Last Few Characters in MySQL Database with SQL Noņemt vai Trim Pirmā vai pēdējo rakstzīmes MySQL Database ar SQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Kā Backup un Restore (Eksporta un importa) MySQL Databases Tutorial
- Reset the Root Password of MySQL Server Reset to Root paroli MySQL Server
- Using phpMyAdmin for Effective MySQL Management in Windows XP Izmantojot phpMyAdmin novērtēšanas MySQL Management Windows XP










































April 2nd, 2009 09:41 Aprīlis 2, 2009 09:41
I'ma newby on managing MySQL. Esmu newby pārvaldības MySQL.
I want to ask you, how to to make sure if the Cron is working? Es gribētu lūgt jūs, par to, kā pārliecināties, ja Cron darbojas?
Thanks Pateicība
November 16th, 2008 12:48 Novembris 16, 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 gar līniju par to, kas Zubin ierosina varat izmantot-klusa (-s) slēdzi, kā arī, lai jūs tikai iegūt izejas, ja ir kļūda, kaut ko līdzīgu
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 Šādā veidā jūs tikai saņemt e-pastu, ja ir kļūda
September 20th, 2008 18:34 Septembris 20, 2008 18:34
Sure mysql does need frequent tunning, and also I have seen a lot of the servers running in the default configuration. Sure mysql nav vajadzīga bieža tunning, kā arī esmu redzējis daudz serveru braukšanu noklusējuma konfigurācijai. which happens to be a very modest one. kas notiek, ir ļoti pieticīgs vienu. If you have access to the mysql configuration file, there are some values that can make your server breathe more often. Ja jums ir piekļuve ar mysql konfigurācijas failu, ir dažas vērtības, kas var dot savu serveri elpot biežāk. And make your visitors more happy. Un, lai jūsu apmeklētāji vairāk laimīgs.
May 6th, 2008 19:15 6 maijs, 2008 19:15
I did not know that it was nesessary to perform a regular check for mysql. Es nezināju, ka bija nesessary veikt regulāri pārbaudītu, mysql.
January 16th, 2008 06:40 Janvāris 16, 2008 06:40
Note that -–auto-repair should have two dashes Jāņem vērā, ka - auto remonta jābūt diviem domuzīmes
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). Tāpat, ja jūs vēlaties atvaļinājuma "> / dev / null", kas paredzēti dažu pirmo sēriju, lai redzētu rezultātus, kā komanda (ja jūs likts mailto = me@mydomain.com augšpusē no crontab, rezultāti kļūs nosūtīja pastāv).