Posts tagged ‘loose’

loose- my.cnf参数prefix

发现一个有意思的参数prefix: –loose-
我们平常使用mysqlbinlog经常会出现错误:
mysqlbinlog: unknown variable ‘default-character-set=utf8’
说不认识这个参数,网上找了一下,发现只要修改my.cnf的client组里面的default-character-set = utf8为loose_default-character-set = utf8,mysqlbinlog就可以正常工作。MySQL5.0和5.1都适用。
这个prefix其实就是让读取该参数的程序不要那么死心眼,如果这个参数自己不解析,那么就当它不存在吧。

拷贝一下MySQL的reference:
4.2.3.2. Program Option Modifiers

Some options are “boolean” and control behavior that can be turned on or off. For example, the mysql client supports a –column-names option that determines whether or not to display a row of column names at the beginning of query results. By default, this option is enabled. However, you may want to disable it in some instances, such as when sending the output of mysql into another program that expects to see only data and not an initial header line.

To disable column names, you can specify the option using any of these forms:

–disable-column-names
–skip-column-names
–column-names=0

The –disable and –skip prefixes and the =0 suffix all have the same effect: They turn the option off.

The “enabled” form of the option may be specified in any of these ways:

–column-names
–enable-column-names
–column-names=1

If an option is prefixed by –loose, a program does not exit with an error if it does not recognize the option, but instead issues only a warning:

shell> mysql –loose-no-such-option
mysql: WARNING: unknown option ‘–no-such-option’

The –loose prefix can be useful when you run programs from multiple installations of MySQL on the same machine and list options in an option file, An option that may not be recognized by all versions of a program can be given using the –loose prefix (or loose in an option file). Versions of the program that recognize the option process it normally, and versions that do not recognize it issue a warning and ignore it.

mysqld enables a limit to be placed on how large client programs can set dynamic system variables. To do this, use a –maximum prefix with the variable name. For example, –maximum-query_cache_size=4M prevents any client from making the query cache size larger than 4MB.