MySQL 5.6.13 was released earlier this week, and in that release (as well as 5.5.33) the ability to use unique option prefixes was deprecated. This is fully removed from MySQL 5.7, and I thought it might be useful to amplify the change log notes on why this was done:
Previously, program options could be specified in full or as any unambiguous prefix. For example, the
--compressoption could be given to mysqldump as
--compr, but not as
--compbecause the latter is ambiguous. Option prefixes now are deprecated. They can cause problems when new options are implemented for programs. A prefix that is currently unambiguous might become ambiguous in the future. If an unambiguous prefix is given, a warning now occurs to provide feedback. For example:Warning: Using unique option prefix compr instead of compress is deprecated and will be removed in a future release. Please use the full name instead.
Option prefixes are no longer supported in MySQL 5.7; only full options are accepted. (Bug #16996656)
I’m not sure the rationale for originally supporting unique option prefixes, but it likely was meant to allow people to use easy-to-remember (and type) shorter versions of option names. The problem is that any option prefix that works with a certain version today may not work tomorrow, as new options are added which may conflict with a given prefix. That means that with any new release, programs (including mysqld) might fail to start due to an option prefix which used to work suddenly becoming ambiguous with the introduction of a new option. It’s not exactly unheard of to add new server options in maintenance releases, while plugins can add new options without even upgrading MySQL. It seemed prudent to deprecate and remove this functionality rather than allow potential conflicts which would adversely affect users randomly, if they use option prefixes.
The most notable area where this change will affect people is in client use, where use of certain prefixes may be common to avoid keystrokes. For example:
[oracle@oraclelinux6 mysql-56]$ bin/mysql -uroot --sock=/path/to/mysql.sock Warning: Using unique option prefix sock instead of socket is deprecated and will be removed in a future release. Please use the full name instead. Welcome to the MySQL monitor. Commands end with ; or \g.
The decision to add deprecation warnings in 5.5 and 5.6 was made to give interactive users visibility to the upcoming removal of this support. For users who leverage option prefixes in scripts or batch files today, and will be adversely affected by the addition of the deprecation warning, we’re hoping to catch all possible affected users at once rather than continue to let users be affected indiscriminately as new options are added in future releases, breaking scripts with random upgrades.
Obviously, the best solution for batch files is to reference an options file with the full option name. Note that the deprecation warning (and future support removal) applies to prefix usage in options files, as well as command-line options:
[oracle@oraclelinux6 mysql-56]$ cat test.cnf [client] sock=/path/to/mysql.sock [oracle@oraclelinux6 mysql-56]$ bin/mysql --defaults-file=test.cnf --user=root Warning: Using unique option prefix sock instead of socket is deprecated and will be removed in a future release. Please use the full name instead. Welcome to the MySQL monitor. Commands end with ; or \g.
By the way, if you like to use “sock” as a prefix for the socket as shown in the above examples, you have an additional option: mysql_config_editor can store socket information:
[oracle@oraclelinux6 mysql-56]$ bin/mysql_config_editor set --login-path=sock \ --socket=/usr/local/mysql-56/data/mysql.sock [oracle@oraclelinux6 mysql-56]$ bin/mysql -uroot ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [oracle@oraclelinux6 mysql-56]$ bin/mysql --login-path=sock -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.13-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
If you use unique options prefixes in options files or batch scripts, please take the time to fix this now before support for this is completely removed in 5.7. Hopefully you can understand how the legacy behavior can lead to deployment-specific problems we can’t anticipate, and the reason behind the deprecation warnings. For those (hopefully very few) who are truly inconvenienced by client deprecation warnings, please consider keeping 5.6.12 or earlier clients, where the deprecation warning doesn’t exist until you can use full option names or options files.