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.

www.it-ebooks.infoCHAPTER 26 • INSTALLING AND CONFIGURING MYSQLSetting the Data Directory LocationIt’s common practice to place the <strong>MySQL</strong> data directory in a nonstandard location, such as on anotherdisk partition. Using the datadir option, you can redefine this path. It’s commonplace to mount asecond drive to a directory, /data for instance, and store the databases in a directory called mysql:%>./bin/mysqld_safe --datadir=/data/mysql --user=mysql &Keep in mind that you need to copy or move the <strong>MySQL</strong> permission tables (stored in DATADIR/mysql)to this new location. Because <strong>MySQL</strong>’s databases are stored in files, you can do so by using operatingsystem commands that are typical for performing such actions, such as mv and cp. If you’re using a GUI,you can drag and drop these files to the new location.Setting the Default Storage EngineAs you’ll learn in Chapter 28, <strong>MySQL</strong> supports several table engines, each of which has its ownadvantages and disadvantages. If you regularly make use of a particular engine (as of version 4.1.5, thedefault is MyISAM on Linux/Unix, and InnoDB on Windows), you might want to set it as the default byusing the --default-storage-engine parameter. For example, you could set the default to MEMORY likeso:%>./bin/mysqld_safe --default-table-type=memoryOnce it is assigned, all subsequent table creation queries will automatically use the MEMORYengine unless otherwise specified.Automatically Executing SQL CommandsYou can execute a series of SQL commands at daemon startup by placing them in a text file andassigning that file name to init_file. Suppose you want to clear a table used for storing sessioninformation with each start of the <strong>MySQL</strong> server. Place the following query in a file namedmysqlinitcmds.sql:DELETE FROM sessions where rowid;Then, assign init_file like so when executing |mysqld_safe:%>./bin/mysqld_safe --init_file=/usr/local/mysql/scripts/mysqlinitcmds.sql &Logging Potentially Nonoptimal QueriesThe log-queries-not-using-indexes parameter defines a file to which all queries are logged that aren’tusing indexes. Regularly reviewing such information could be useful for discovering possibleimprovements to your queries and table structures.499

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

Saved successfully!

Ooh no, something went wrong!