Setting Variables for MySQL

Without being set explicitly, the variables for the MySQL server and other MySQL programs will be at their default values. However, for various reasons, you may want to adjust these from the default: to improve performance, to turn on or off things, or simply to make programs run more conveniently.

The easiest way to set variables is by using a my.cnf file (or for Windows, it may be my.cnf or my.ini).

The my.cnf or my.ini file may contain several sections' worth of variables: usually a section for mysqld itself; and optionally sections for other programs, such as mysql, mysqldump, and myisamchk. Here's a short extract of one, including sections for client and mysqld:

 # Settings for all MySQL clients: [client] port ...

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.