11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 27 • THE MANY MYSQL CLIENTSwww.it-ebooks.infoVarying degrees of checks are also available, each of which requires additional time but morethoroughly reviews the table for errors. Although the default is simply check (--check), there also exists amedium check (--medium-check) and an extended check (--extend-check). Only use the extended checkfor the most severe cases; the medium check will catch the overwhelming majority of errors andconsume considerably less time. You can review extended information for each of these checks bysupplying the --information (-i) option, which offers various table-specific statistics.If problems are identified with the table, you’ll be notified accordingly. If an error is found, you canask myisamchk to attempt to repair it by supplying the --recover (-r) option:%>myisamchk -r /usr/local/mysql/data/corporate/staff.MYINote that what is presented here is just a smattering of the options available to this utility. Definitelyconsult the manual before using myisamchk to check or repair tables. Also, you should only run myisamchkwhen the <strong>MySQL</strong> server daemon is not running. If you don’t have the luxury of taking your databaseserver offline, take a look at the next utility, mysqlcheck.mysqlcheckThe mysqlcheck utility offers users the means for checking and, if necessary, repairing corrupted tableswhile the <strong>MySQL</strong> server daemon is running. It can be invoked in any of the three following ways:%>mysqlcheck [options] database [tables]%>mysqlcheck [options] --databases database1 [database2...]%>mysqlcheck [options] --all-databasesIn addition to the typical user credentials and concerned databases and tables, you can specifywhether you want to analyze (-a), repair (-r), or optimize (-o) by passing in the appropriate parameter.So, for example, suppose the staff table, located in the database corporate, became corrupted due tosudden hard-drive failure. You could repair it by executing:%>mysqlcheck -r corporate staffLike myisamchk, mysqlcheck is capable of finding and repairing the overwhelming majority of errors.In addition, it offers a wide-ranging array of features. Therefore, before you use it to resolve any missioncriticalproblems, take some time to consult the <strong>MySQL</strong> manual to ensure that you’re using the mosteffective set of options.Client OptionsThis section highlights several of the options shared by many of <strong>MySQL</strong>’s clients, mysql and mysqladminincluded. The options are divided into two categories: connection options and general options. Beforemoving on to a breakdown of the options falling under these two categories, take a moment to review afew simple rules that you should keep in mind when using these options:• Options can be passed to clients in three ways: via the command line, environmentvariables, or configuration files. If you plan on using a particular option repeatedly, thepreferred way to set it is through a configuration file. <strong>MySQL</strong>’s configuration files werefirst introduced in Chapter 26.520

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!